Switch between sections of one view: the indicator stretches along the baseline, the panel arrives from the direction of travel, with counts, lazy panels and deep links.
Click meTap me
Payments API
/projects/payments-api
Healthy
Requests
1.28M
last 24h
p95 latency
182 ms
−6% this week
Error rate
0.12%
under the 0.5% budget
3 new events since your last visit
Latest: Webhook retries paused
Webhook retries paused (new)
Alex
4m ago
Deploy to staging finished (new)
CI
18m ago
API key rotated (new)
Sam
1h ago
Invoice #2041 marked paid
Billing
3h ago
SSam
Owner
AAlex
Admin
RRobin
Developer
KKai
Viewer
tabs · , lively
tabs-demo.tsx
When to use
Use it to switch between sections of one view, where each tab owns a panel of content. Supports count badges, panels that load on first open, a vertical layout and deep links with urlParam.
Tabs switch between sections of one view: a project's overview, activity, members and settings; a support queue's open, waiting and solved tickets; the sections of an account page. Each tab owns a panel of content (role="tablist" and tabpanel), can show how much that panel holds (TabsBadge), can load it on first open (loading) and can keep it in the URL so it is linkable (urlParam). The panel is the hero: it travels in from the side you moved toward.
If nothing under the control changes but a value does (a setting, a form field), use a segmented control. For moving between pages, use the sidebar or a breadcrumb.
The motion follows the three beats. Pressing a tab charges: its label sinks and the pill's edge nudges 2 px toward it. On release the pill acts: its leading edge springs to the new tab while the trailing edge follows a little later, so it stretches over the travel, and each label takes the active color when the pill reaches it. The new panel arrives from the side you moved toward, its sections one stagger step apart, while the old one fades out through the other side just before the new one comes up: the two never read on top of each other, and the card never reads empty. It then settles: the pill contracts onto the tab and the panel's height reflows on the calm spring, slower for taller changes so the content below glides instead of jumping. calm glides without bounce, playful stretches and bounces more.
TabsPanels wraps every TabsContent: it knows the direction of travel, keeps the leaving panel for its exit and reflows the height. Without it, panels fade in place. reserve holds the tallest panel's height instead, so a switch never moves the list or what surrounds it (a card centered in its container, a dialog); the demos use it.
TabsSection children placed directly inside a TabsContent arrive one stagger step apart. Without sections, the panel arrives as one block.
Controlled with value and onValueChange, or uncontrolled with defaultValue. activationMode="manual" makes arrow keys move focus only; Enter or Space selects.
preset picks the layout (underline, pill, vertical), size the height (sm 32 px, md 36 px, lg 40 px), fullWidth shares the width equally, swipeable lets a horizontal swipe on the panels change tab.
A horizontal list that does not fit scrolls inside itself (never the page), with a fade on the clipped side; the pill scrolls with the labels and the active tab scrolls into view. With fullWidth, a label is never squeezed under its own width: past that point the list scrolls the same way.
invalid on a trigger shows a small destructive dot (a settings form split in tabs where one tab holds errors).
TabsBadge inside a trigger shows how much its panel holds. count rolls up or down with the change; at 0 the badge shrinks out and the tab closes the gap with the indicator following (showZero keeps it). tone="neutral" (default) is muted and turns solid on the active tab; tone="primary" is solid everywhere, for something waiting (unread, failing). label is read after the number ("Activity 3 new"); max (99) caps it at 99+.
loading on a TabsContent shows a skeleton (or your fallback) and marks the panel aria-busy; when it turns off, the panel's TabsSections arrive in their cascade. Use it for panels fetched on first open.
urlParam="tab" keeps the active tab in the URL (?tab=members): a reload or a shared link opens that tab in place, without travel. Each change replaces the URL (no history entry per tab) and keeps other parameters; the initial tab removes the parameter. It reads window.location after hydration, so it is SSR-safe; with a router that owns the URL, control value from its search params instead.
forceMount on a TabsContent keeps it mounted while inactive (only hidden) so a form keeps its state; such a panel fades in instead of travelling.
The default demo above: a project card with Overview, Activity, Members and Settings, kept in the URL with urlParam="tab" (the line under the title mirrors it; reload this page with ?tab=members and Members opens). Activity carries a primary badge with 3 new events, highlighted in its panel; leaving the tab marks them read and the badge rolls out. Members loads on first open: a skeleton, then the rows cascade in. At 320 px the list drops to sm and scrolls with a fade on the clipped side; the active tab scrolls into view.
The pill preset is for a panel switcher in a card's header: a raised capsule in a sunken track, here with ticket counts per queue. It still switches panels; to pick a value, use a segmented control.
Labels in a column; the pill becomes a rail on the inner edge with a capsule behind the active label, and panels arrive from below or above. Security is invalid, Billing is disabled. Below 480 px the demo switches to the underline preset so the list sits above full-width fields.
Built on Radix Tabs: role="tablist" with aria-orientation, role="tab" with aria-selected and aria-controls, role="tabpanel" with aria-labelledby.
Name the list with aria-label or aria-labelledby (a development warning reminds you). Icon-only tabs need an aria-label.
The pill, the rail, the hover capsule and the error dot are aria-hidden. An invalid tab is described as "Contains errors" through aria-describedby.
A TabsBadge adds its count (and label) to the tab's name once ("Activity 3 new"); the rolling digits are aria-hidden, so a roll never reads two numbers.
A loading panel is aria-busy and contains a visually hidden "Loading"; the skeleton itself is hidden from assistive technology.
The leaving panel is inert during its exit, so focus never lands in content that is going away.
Focus shows a 3 px inset ring in the theme's ring color on tabs and panels, above the pill and never clipped by a scrolling list. A tab focused by a click shows no ring; the next key press brings it back.
Disabled labels stay at 80% so they keep at least 3:1 contrast.
Inactive labels use muted-foreground, the active one foreground; the selection is also carried by the pill's shape. The 2 px primary underline meets 3:1 against background.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") there is no label sink and no nudge. The pill still travels so the eye can follow it, but both edges glide together in the short fade time, without stretch or bounce. The old panel fades out quickly and the new one fades in place just behind it, its sections together, so the two never show on top of each other; the height follows in the same fade, with the leaving panel clipped to it. Hover capsules and focus rings still respond. Badge counts change with a fade instead of a roll, and the skeleton does not pulse. A tab restored from the URL is shown in place in every mode.
The pill moves with transform and its size from motion values; label colors follow the pill through attributes, so React does not re-render while it travels.
Panels slide with transform and opacity. The one layout property animated is the panel container's height, on the calm spring, only while the height actually changes; it returns to auto afterwards.
Tab positions are measured on selection change and by a ResizeObserver, so the pill stays aligned when the container resizes or fonts load.
Nothing runs at rest: there is no ambient loop to pause off-screen or in hidden tabs.
A badge animates its own width as it appears or leaves (so the tab and indicator follow instead of jumping); every other badge motion is transform and opacity.
The only loop is the skeleton's CSS pulse, and only while a panel is loading.
No lazy-loaded parts; peers are motion and @radix-ui/react-tabs.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-tabs, motion.
Dependencies
@radix-ui/react-tabs · peer
motion · peer
Triggers
click, press, keyboard focus
Reduced motion
No sink or nudge: the pill glides to the new tab in the fade time, the old panel fades out and the new one fades in place. Badge counts fade instead of rolling; the skeleton does not pulse.
Keyboard
Tab
Focuses the active tab; Tab again moves into the active panel