# Tabs

A set of layered sections of content displayed one at a time.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

<DocsBaseSwitcher base="web" component="tabs" />

<ComponentPreview name="tabs" title="tabs.tsx">
<TabsDemo />
</ComponentPreview>

Tabs organize related content into panels that switch in place. Only one panel is visible at a time, keeping dense interfaces compact.

## Installation [#installation]

<CodeTabs>
<TabsList>
<TabsTrigger value="cli">
Command
</TabsTrigger>

<TabsTrigger value="manual">
Manual
</TabsTrigger>
</TabsList>

<TabsContent value="cli">
~~~bash
npx frakment add tabs
~~~
</TabsContent>

<TabsContent value="manual">
<Steps>
<Step>
Copy and paste the following code into your project.
</Step>

<ComponentSource name="tabs" title="components/ui/tabs.tsx" />

<Step>
Update the import paths to match your project setup.
</Step>
</Steps>
</TabsContent>
</CodeTabs>

## Usage [#usage]

~~~tsx title="tabs.tsx"
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@/components/ui/tabs";
~~~

~~~tsx title="tabs.tsx"
<Tabs defaultValue="account">
  <TabsList>
    <TabsTrigger value="account">Account</TabsTrigger>
    <TabsTrigger value="password">Password</TabsTrigger>
  </TabsList>
  <TabsContent value="account">Account settings.</TabsContent>
  <TabsContent value="password">Password settings.</TabsContent>
</Tabs>
~~~

## Composition [#composition]

```text
Tabs
├── TabsList
│   └── TabsTrigger
└── TabsContent
```

## Examples [#examples]

### Vertical [#vertical]

Set `orientation="vertical"` to stack triggers beside the panel.

<ComponentPreview name="tabs-vertical" title="tabs-vertical.tsx" src="examples/tabs-vertical.tsx">
<TabsVertical />
</ComponentPreview>

### Disabled [#disabled]

Set `disabled` on a trigger to prevent selection.

<ComponentPreview name="tabs-disabled" title="tabs-disabled.tsx" src="examples/tabs-disabled.tsx">
<TabsDisabled />
</ComponentPreview>

### With icons [#with-icons]

Triggers accept icons before the label. Icons size themselves via `[&_svg]:size-4`.

<ComponentPreview name="tabs-icons" title="tabs-icons.tsx" src="examples/tabs-icons.tsx">
<TabsIcons />
</ComponentPreview>

## In Context [#in-context]

### Docs tabs [#docs-tabs]

<ComponentPreview name="tabs-docs" title="tabs-docs.tsx" src="examples/tabs-docs.tsx">
<TabsDocs />
</ComponentPreview>

## API Reference [#api-reference]

### Tabs [#tabs]

<PropsTable rows={[{"name":"defaultValue","type":"string","description":"Value of the tab open on first render."},{"name":"value","type":"string","description":"Controlled value of the open tab."},{"name":"onValueChange","type":"function","description":"Called when the active tab changes."},{"name":"orientation","type":"horizontal | vertical","default":"horizontal","description":"Layout axis of the tab list."}]} />

### TabsList [#tabslist]

<PropsTable rows={[{"name":"motion","type":"string","default":"260 cubic-bezier(0.22, 1, 0.36, 1)","description":"Timing for the active-tab indicator slide. Set to off to disable, or pass duration + easing like 150 ease-out."}]} />

The active-tab background slides between triggers using the Web Animations API. The default is 260ms with a smooth-out curve.

```tsx
<TabsList motion="400 ease-in-out">
  <TabsTrigger value="account">Account</TabsTrigger>
  <TabsTrigger value="password">Password</TabsTrigger>
</TabsList>
```

Set motion="off" to snap the indicator without animation. prefers-reduced-motion disables the slide automatically.

### TabsTrigger [#tabstrigger]

<PropsTable rows={[{"name":"value","type":"string","description":"Identifier matching the associated TabsContent."},{"name":"disabled","type":"boolean","default":"false","description":"Prevent the trigger from being selected."}]} />

## As Prop [#as-prop]

`TabsContent` accepts `as` to render a custom element. `TabsTrigger` renders a native `<button>` by default.

## Controlled [#controlled]

```tsx
const [value, setValue] = React.useState("tab-1")
<Tabs value={value} onValueChange={setValue}>{/* ... */}</Tabs>
```

## Keyboard [#keyboard]

| Key | Action |
| :-- | :-- |
| `←` / `→` | Move between triggers (horizontal) |
| `↑` / `↓` | Move between triggers (vertical) |
| `Home` / `End` | First / last trigger |
| `Enter` / `Space` | Activate focused trigger |

## Data Attributes [#data-attributes]

| Attribute | Values |
| :-- | :-- |
| `data-slot` | `tabs`, `tabs-list`, `tabs-trigger`, `tabs-content` |
| `data-state` | `active` \| `inactive` |
| `data-orientation` | `horizontal` \| `vertical` |

## Accessibility [#accessibility]

- Follows the WAI-ARIA tabs pattern.
- Triggers expose `role="tab"` and `aria-selected`.
- Keyboard: `ArrowLeft` and `ArrowRight` move between triggers.

## Best Practices [#best-practices]

- **Keep tabs to three or four.** More tabs become a nav, not a tab list.
- **Pick a default.** Empty tab groups confuse users about the current state.
- **Do not nest tabs.** Nested tabs lose context; use a segmented control instead.
- **Do not lazy-load the first tab.** The default tab should not flash.
## Related Components [#related-components]

- [Accordion](/docs/components/accordion) — stacked collapsible sections
- [Breadcrumb](/docs/components/breadcrumb) — navigate between pages