Tabs
Switch between views of the same object without leaving the page.
Playground
Tabs switch between views of the same object. The pill variant suits compact toolbars; the line variant sits on top of a panel or record.
Overview
Summary, owner and next step for the project.
Props
1import { Activity, FileText, LayoutGrid, Settings } from "lucide-react"2import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"34<Tabs defaultValue="overview">5 <TabsList>6 <TabsTrigger value="overview">7 <LayoutGrid />8 Overview9 </TabsTrigger>10 <TabsTrigger value="activity">11 <Activity />12 Activity13 <span className="rounded-full bg-muted px-1.5 text-xs">12</span>14 </TabsTrigger>15 <TabsTrigger value="files">16 <FileText />17 Files18 <span className="rounded-full bg-muted px-1.5 text-xs">3</span>19 </TabsTrigger>20 <TabsTrigger value="settings">21 <Settings />22 Settings23 </TabsTrigger>24 </TabsList>25 <TabsContent value="overview">…</TabsContent>26 <TabsContent value="activity">…</TabsContent>27 <TabsContent value="files">…</TabsContent>28 <TabsContent value="settings">…</TabsContent>29</Tabs>Automatic activation shows a panel as soon as its tab gets focus. Manual moves focus with the arrow keys and waits for Enter or Space, which is better when panels are slow to render.
States
States of a single TabsTrigger. Active is the raised pill in the playground; these are the inactive trigger's states.
- Default
rest - Hover
:hover - Focus
:focus-visible - Loading
aria-busy - Disabled
disabled - Error
errors in panel - Success
step complete
Patterns
Line tabs over a record with counts in the triggers, and the shared ViewSwitcher, a segmented control whose pill slides between views.
Globex enterprise rollout
Updated Sep 28
Projects
- Customer portalBuilding
- Billing migrationReview
- Onboarding emailsDone
Keyboard
- Into the tab list, then into the panel
- Tab
- Previous or next tab (horizontal)
- ←or→
- Previous or next tab (vertical)
- ↑or↓
- First or last tab
- HomeorEnd
- Activate the focused tab (manual)
- EnterorSpace
Semantics and ARIA
- Renders
tablist,tabandtabpanel. Each tab hasaria-selectedandaria-controls; each panel is labelled by its tab. - Only the active tab is in the tab order (roving tabindex), so Tab jumps straight from the list into the panel.
- Count badges are part of the tab name (“Activity 12”). Keep them short numbers; don’t put buttons inside a tab.
- ViewSwitcher uses
tablistandtabsemantics with click and Tab navigation. It switches the view of the same content, so it has no separate panels. - Tabs are not navigation. If each option is its own page with a URL, use links in a nav instead.