Animated Background

Visually highlights selected items by sliding a background into view when hovered over or clicked. This smooth transition helps users focus on the active item, making it ideal for interactive lists, menus, or navigations where clear selection feedback is important.',

Examples

Animated Tabs

Animated Tabs Hover

Animated Card Background

Inbox

Mentions and replies waiting for you.

Calendar

Every meeting of the team in one week view.

Boards

Plan a launch from first idea to release.

Documents

Specs and notes that stay next to the work.

Reports

Time spent per project, updated each night.

Automations

Move a card when a pull request is merged.

Segmented Control

Installation

npx shadcn@latest add https://ui.ndekocode.dev/r/motion-animated-background.json

Component API

PropTypeDefaultDescription
childrenReactElement with 'data-id' string attribute array or single elementThe content to be displayed within the animated background. Each child must have a unique data-id attribute to ensure correct functionality.
defaultValuestringThe default value to be used as the active item identifier.
onValueChange(newActiveId: string | null) => voidCallback function that is called when the active item changes.
classNamestringThe class name to apply to the animated background for custom styling.
transitionTransitionThe transition effect from motion for animation effects.
enableHoverbooleanfalseEnables or disables the hover effect. When enableHover is true, spacing between children cannot be added.