Motion Highlight
edgecom/motion-highlightFreeComponent
The Edgecom Motion Highlight component.
Install it
npx shadcn@latest add https://design.edgecom.ai/r/motion-highlight.jsonSource
1'use client'23/* Vendored Animate UI component. Its hook patterns (controlled-value sync,4 manual memoization) trip the React Compiler's optimization lints; disable5 them here rather than rewriting third-party code and risking behavior drift. */6/* eslint-disable react-hooks/preserve-manual-memoization, react-hooks/set-state-in-effect */78import * as React from 'react'910import type { Transition } from 'motion/react'11import { AnimatePresence, motion } from 'motion/react'1213import { cn } from '@/lib/utils'1415type MotionHighlightMode = 'children' | 'parent'1617type Bounds = {18 top: number19 left: number20 width: number21 height: number22}2324type MotionHighlightContextType<T extends string> = {25 mode: MotionHighlightMode26 activeValue: T | null27 setActiveValue: (value: T | null) => void28 setBounds: (bounds: DOMRect) => void29 clearBounds: () => void30 id: string31 hover: boolean32 className?: string33 activeClassName?: string34 setActiveClassName: (className: string) => void35 transition?: Transition36 disabled?: boolean37 enabled?: boolean38 exitDelay?: number39 forceUpdateBounds?: boolean40}4142const MotionHighlightContext = React.createContext<43 // eslint-disable-next-line @typescript-eslint/no-explicit-any44 MotionHighlightContextType<any> | undefined45>(undefined)4647function useMotionHighlight<T extends string>(): MotionHighlightContextType<T> {48 const context = React.useContext(MotionHighlightContext)4950 if (!context) {51 throw new Error('useMotionHighlight must be used within a MotionHighlightProvider')52 }5354 return context as unknown as MotionHighlightContextType<T>55}5657type BaseMotionHighlightProps<T extends string> = {58 mode?: MotionHighlightMode59 value?: T | null60 defaultValue?: T | null61 onValueChange?: (value: T | null) => void62 className?: string63 transition?: Transition64 hover?: boolean65 disabled?: boolean66 enabled?: boolean67 exitDelay?: number68}6970type ParentModeMotionHighlightProps = {71 boundsOffset?: Partial<Bounds>72 containerClassName?: string73 forceUpdateBounds?: boolean74}7576type ControlledParentModeMotionHighlightProps<T extends string> = BaseMotionHighlightProps<T> &77 ParentModeMotionHighlightProps & {78 mode: 'parent'79 controlledItems: true80 children: React.ReactNode81 }8283type ControlledChildrenModeMotionHighlightProps<T extends string> = BaseMotionHighlightProps<T> & {84 mode?: 'children' | undefined85 controlledItems: true86 children: React.ReactNode87}8889// … truncated
What it pulls in
Other registry items
Files it writes
More from edgecom
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | edgecom | Components | Free | 2 deps | |
| Alertalert | edgecom | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | edgecom | Components | Free | 1 dep | |
| Avataravatar | edgecom | Components | Free | 1 dep | |
| Badgebadge | edgecom | Components | Free | 2 deps | |
| Bannerbanner | edgecom | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | edgecom | Components | Free | 2 deps | |
| Buttonbutton | edgecom | Components | Free | 2 deps |
