Animated Tabs
Tabs with a gliding pill and panels stacked like cards that peek behind.
- 1.9 KB gzipped
- Deps: motion/react
- Reduced-motion safe
- Base UI & Radix compatible
Sketch in the browser
Start from tokens, not pixels. Every colour and radius maps to a CSS variable you can re-theme later.
Installation
pnpm dlx shadcn@latest add https://velora.colorlib.com/r/animated-tabs.jsonAdds components/velora/animated-tabs.tsx, installs motion.
Examples
Product feature tour
Four tabs of rich content, each with copy, a checklist and a mock UI.
Analytics
See what moves the needle
Live dashboards that update as events arrive — no nightly batch jobs.
- Funnels and retention
- Custom events
- CSV and API export
Props
| Prop | Type | Default |
|---|---|---|
tabs*The tabs, in order | Tab[] | — |
defaultValueValue of the tab selected on first render (defaults to the first tab) | string | — |
valueControlled selected value | string | — |
onValueChangeCalled with the new value when the selection changes | (value: string) => void | — |
peekHow many inactive panels peek out behind the active one | number | 2 |
listClassNameClasses for the tab list | string | — |
panelClassNameClasses for every panel card | string | — |
Also accepts every <div> attribute, forwarded to the root element.
Tab
interface Tab {
title: React.ReactNode;
value: string;
content: React.ReactNode;
}Accessibility
- Reduced motion
- The pill jumps to the selected tab and the panels swap places instantly; the stacked, offset layout stays as a static picture.
- Keyboard
- One Tab stop for the tab list (roving tabindex). Arrow Left/Right move and select with wrap-around, Home and End jump to the first and last tab, and Tab then moves into the active panel.
- Screen readers
- Uses tablist, tab and tabpanel roles with aria-selected, aria-controls and aria-labelledby; the peeking inactive panels are aria-hidden and inert.