Animated Background
newA highlight that slides behind the active or hovered item.
Installation
npx shadcn@latest add @blank/animated-backgroundUsage
import { AnimatedBackground } from "@/components/ui/animated-background"<AnimatedBackground defaultValue="a" className="rounded-full bg-item-secondary">
<button data-id="a">Overview</button>
<button data-id="b">Settings</button>
</AnimatedBackground>Every child with a data-id gets the highlight behind it when its id is the
value, plus data-active="true" to style its own content. The highlight is
absolutely positioned, so nothing moves when it appears. With reduced motion it
jumps instead of sliding.
AnimatedBackground renders no element of its own: put it inside the list, menu or tab bar that owns the semantics.
Examples
Hover
enableHover follows the pointer and keyboard focus, and clears when both
leave — a menu or a nav list rather than a selection.
API Reference
| Prop | Type | Default |
|---|---|---|
value / defaultValue | string | null | null |
onValueChange | (value: string | null) => void | — |
enableHover | boolean | false |
className | string | — (the highlight's classes) |
transition | motion Transition | a short spring |