Tabs
Splits content into switchable tabs on a single screen, allowing users to view different sections of related information without reloading the page.
3.4 KB
•Updated on August 21, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/primitives-tabsUsage
Code
import { Tabs, TabsList, TabsPanel, TabsTab } from '@/components/ui/tabs'Code
<Tabs defaultValue="tab-1">
<TabsList>
<TabsTab value="tab-1">Tab 1</TabsTab>
<TabsTab value="tab-2">Tab 2</TabsTab>
<TabsTab value="tab-3">Tab 3</TabsTab>
</TabsList>
<TabsPanel value="tab-1">Tab 1 content</TabsPanel>
<TabsPanel value="tab-2">Tab 2 content</TabsPanel>
<TabsPanel value="tab-3">Tab 3 content</TabsPanel>
</Tabs>Anatomy
Code
<Tabs>
<TabsList>
<TabsTab />
<TabsIndicator />
</TabsList>
<TabsPanel />
</Tabs>Features
Variants
Tabs in rounded button style (default) and border line style (underline).
Sizes
Tabs triggers in sm, default, and lg sizes.
Accessibility
- Follows the WAI-ARIA Tabs Pattern.
- Tab triggers and panels are linked via
aria-controlsandaria-labelledby.
Keyboard Interactions
| Key | Action |
|---|---|
| ArrowRight / ArrowDown | Moves focus to the next tab and activates its panel. |
| ArrowLeft / ArrowUp | Moves focus to the previous tab and activates its panel. |
| Home | Jumps to and activates the first tab. |
| End | Jumps to and activates the last tab. |
Vertical Orientation
Tabs navigation arranged vertically using orientation="vertical".
API Reference
Tabs
Root component. Styled wrapper for Tabs.Root from Base UI.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | default|underline | default | Controls the tabs styling |
TabsList
Container for tab triggers. Styled wrapper for Tabs.List from Base UI.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | default|underline | default | Controls the tabs list variant |
size | sm|default|lg | default | Controls the height and padding across all child tabs |
TabsTab
Individual tab trigger. Styled wrapper for Tabs.Tab from Base UI. Also exported as TabsTrigger.
| Prop | Type | Default | Description |
|---|---|---|---|
size | sm|default|lg | default | Controls the specific tab trigger dimension |
TabsPanel
Content panel for each tab. Styled wrapper for Tabs.Panel from Base UI. Also exported as TabsContent.
TabsIndicator
Visual indicator for the active tab. Styled wrapper for Tabs.Indicator from Base UI.
Examples
Tabs with full rounded triggers
Tabs with icon before name
Tabs with icon before name and underline
Tabs with icon only
Tabs with underline and icon on top
Tabs with count badge
Tabs with icon only and count badge
Tabs with icon only and grouped tooltips