Components
Tabs
Segmented control that switches between panels sharing the same space, with a sliding active indicator.
import { Tabs } from "@openperf/deft";
<Tabs.Root defaultValue="claude">
<Tabs.List aria-label="Assistant">
<Tabs.Tab value="claude">Claude</Tabs.Tab>
<Tabs.Tab value="codex">Codex</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="claude">Run the Claude command.</Tabs.Panel>
<Tabs.Panel value="codex">Run the Codex command.</Tabs.Panel>
</Tabs.Root>;When to use
| Need | Component |
|---|---|
| A few alternative views of the same content | Tabs |
| Every tab is a card with a headline number | Metric |
| Moving between pages, not views of the same content | Sidebar |
Anatomy
<Tabs.Root>
<Tabs.List>
{/* the list draws the active indicator itself */}
<Tabs.Tab value="a" />
</Tabs.List>
<Tabs.Panel value="a" /> {/* shown while the tab with the same value is active */}
</Tabs.Root>Tabs.Root stacks the list and the panels in a column. To put a control next to the list, wrap both in a row inside the root.
Layout
Tabs are 22px high and size Tabler icons inside them to 14px. Tabs.List is as wide as its tabs and scrolls sideways when they do not fit. A tab with disabled is dimmed and ignores clicks.
API
No part declares props of its own; each takes the props of the Base UI Tabs part of the same name.
| Part | Props used most |
|---|---|
Tabs.Root | defaultValue, or value with onValueChange. |
Tabs.List | aria-label to say what the tabs switch. activateOnFocus activates a tab on arrow-key focus instead of Enter or Space. |
Tabs.Tab | value (required), disabled. |
Tabs.Panel | value (required), keepMounted to keep a hidden panel in the DOM. |