Components / Navigation
Animated Tabs
A tab bar with a pill that springs smoothly to the selected tab.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/animated-tabs.tsx. - 3
Use it
example.tsximport { AnimatedTabs } from "@/components/ui/animated-tabs"; export default function AnimatedTabsDemo() { return ( <AnimatedTabs tabs={[ { id: "overview", label: "Overview" }, { id: "analytics", label: "Analytics" }, { id: "reports", label: "Reports" }, { id: "settings", label: "Settings" }, ]} /> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| tabs | { id: string; label: string }[] | — | The tabs to show. |
| defaultTab | string | — | Id of the tab selected at first. Defaults to the first tab. |
| onChange | (id: string) => void | — | Called when the selected tab changes. |