Tabs
The key stretches across the list to the tab you pick, and the panel slides in from that side.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/tabsThis adds components/keyframery/tabs.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab } from "@/components/keyframery/tabs"
export default function Usage() {
return (
<Tabs defaultValue="account">
<TabsList aria-label="Settings">
<TabsTab value="account">Account</TabsTab>
<TabsTab value="password">Password</TabsTab>
</TabsList>
<TabsPanels>
<TabsPanel value="account">Account settings</TabsPanel>
<TabsPanel value="password">Password settings</TabsPanel>
</TabsPanels>
</Tabs>
)
}Anatomy
How the parts fit together:
Tabs
├── TabsList
│ └── TabsTab
└── TabsPanels
└── TabsPanelExamples
Basic
The key glides to the chosen tab, and the panels slide in from the side you moved towards.
Controlled
Pass value and onValueChange, for example to keep the tab in the URL.
Vertical
orientation="vertical" lists the tabs down the side. Up and down arrows move between them.
Icons
TabsTabIcon holds an icon inside a tab. Screen readers skip it, so a tab with only an icon needs an aria-label.
Motion
| Move | What you see |
|---|---|
| Stretch | The key stretches across the list toward the tab you pick, then closes up. |
| Fade | Label colours flip exactly at the key's edge as it passes. |
| Direction | The panel slides in from the side you moved to. |
Timing and springiness follow the motion style you set. To change how fast this tabs moves, pass speed:
<Tabs speed="fast">
…
</Tabs>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--tabs-track | Tab list well | --muted |
--tabs-key | Selected tab surface | --background; --accent in dark |
--tabs-ink | Unselected labels | --muted-foreground |
--tabs-selected-ink | Selected labels | --foreground |
--tabs-height | Tab height | 2rem |
--tabs-radius | List corners | 12px |
--tabs-key-radius | Tab key corners | 9px |
--tabs-gap | Space between tabs | 0.125rem |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK tabs reference.
Tabs
Renders a <div>, and takes its props too.
Prop
Type
TabsTab
Renders a <button>, and takes its props too.
Prop
Type
TabsPanel
Renders a <div>, and takes its props too.
Prop
Type
TabsTabIcon
Renders a <span>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
TabsList: a<div>TabsPanels: a<div>TabsIndicator: a<span>
Keyboard
| Key | What it does |
|---|---|
| ← → | Moves to the previous or next tab. |
| Home | Moves to the first tab. |
| End | Moves to the last tab. |
| Enter | Selects the focused tab, with manual activation. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's tabs with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/tabs"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/tabs"Questions
How does the animated Tabs for UI SDK move?
Stretch: The key stretches across the list toward the tab you pick, then closes up. Fade: Label colours flip exactly at the key's edge as it passes. Direction: The panel slides in from the side you moved to.
Do I need Motion or Framer Motion for the animated Tabs?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/tabs instead. It has the same parts and props as @ui-sdk/react/tabs and adds motion only.
What happens to the Tabs when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in Navigation
All componentsStepper
Steps that are complete, current, upcoming or in error, horizontal or vertical, as a read-only progress strip (an order) or the buttons of a multi-step form, linear or not. The line between steps draws itself up to the current one, a finished step's number gives way to a check that draws itself, and panels arrive from the side you moved toward.
Tree
Branches open on a spring with their rows falling in, and the selected row's key glides.