A shared motion highlight that slides between items on hover, or fades per-item on click.
Made by AxylExamples
Click Mode
Installation
Usage
Parent mode — shared sliding element
One motion.div lives inside the container and slides to whichever item is active. This is the same pattern used by the sidebar hover highlight.
Children mode — per-item fade
Each item renders its own motion.div overlay. Framer Motion's layoutId animates between items on click.
Controlled value
Props
Highlight
| Prop | Type | Default |
|---|---|---|
mode? | "parent" | "children" | "children" |
trigger? | "hover" | "click" | "click" |
value? | string | null | - |
defaultValue? | string | null | - |
onValueChange? | (value: string | null) => void | - |
className? | string | - |
style? | CSSProperties | - |
transition? | Transition | { type: "spring", stiffness: 350, damping: 35 } |
exitDelay? | number | 0 |
disabled? | boolean | false |
containerClassName? | string | - |
boundsOffset? | Partial<{ top: number; left: number; width: number; height: number }> | - |
HighlightItem
| Prop | Type | Default |
|---|---|---|
value? | string | - |
disabled? | boolean | false |
activeClassName? | string | - |
className? | string | - |
style? | CSSProperties | - |
transition? | Transition | - |
asChild? | boolean | false |
When to Use
Use mode="parent" for navigation bars, tab rows, and any horizontal/vertical list where you want one smooth background element sliding between items. The spring physics make the motion feel natural even when the cursor skips quickly across items.
Use mode="children" for menus, sidebars, and selection lists where each item independently fades in its background. The shared layoutId cross-fades between items on click.
Avoid using trigger="hover" with mode="children" and widely-spaced items — the per-item fade-in/out can feel noisy. In that case, prefer mode="parent" which slides a single element.
Accessibility
HighlightItem sets aria-selected and data-active on each item wrapper. The highlight overlay itself is decorative (pointer-events-none) and invisible to assistive technologies. Keyboard navigation is not wired automatically — connect it via the controlled value/onValueChange API if needed.
When prefers-reduced-motion: reduce is set, Framer Motion automatically reduces the spring animation to a simple fade.
Built by Axyl. A motion-first component registry for React.
Last updated: 6/30/2026