Navigation
Tabs
Switches between panels of related content on one page, such as the sections of a website. Pick a style on Tabs.List: a quiet segmented control, a dark pill bar or nav-style underline tabs.
import * as Tabs from '@statix/ui/tabs';Playground
<Tabs.Root value="overview">
<Tabs.List variant="pill" aria-label="yoga-berger.de">
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="backups">Backups</Tabs.Trigger>
<Tabs.Trigger value="updates">Updates</Tabs.Trigger>
<Tabs.Trigger value="settings">Settings</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="overview">…</Tabs.Content>
<Tabs.Content value="backups">…</Tabs.Content>
</Tabs.Root>Examples
Default
A white segment on a bg-2 track. Use it for two or three short options inside a card, such as a billing period.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
</script>
<Tabs.Root value="month" class="w-full max-w-md">
<Tabs.List aria-label="Billing period">
<Tabs.Trigger value="month">Monthly</Tabs.Trigger>
<Tabs.Trigger value="year">Yearly</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="month" class="text-ink-2"
>WordPress Hosting costs 19 € per month.</Tabs.Content
>
<Tabs.Content value="year" class="text-ink-2">
WordPress Hosting costs 190 € per year. You save two months.
</Tabs.Content>
</Tabs.Root>Pill
The dark segmented bar from the website detail page. Use it for the main sections of one object.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
</script>
<Tabs.Root value="overview" class="w-full max-w-2xl items-start">
<Tabs.List variant="pill" aria-label="yoga-berger.de">
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="backups">Backups</Tabs.Trigger>
<Tabs.Trigger value="updates">Updates</Tabs.Trigger>
<Tabs.Trigger value="settings">Settings</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="overview" class="text-ink-2">
yoga-berger.de is online. WordPress 6.7, PHP 8.3.
</Tabs.Content>
<Tabs.Content value="backups" class="text-ink-2">Last backup today at 03:10.</Tabs.Content>
<Tabs.Content value="updates" class="text-ink-2">All plugins are up to date.</Tabs.Content>
<Tabs.Content value="settings" class="text-ink-2">Domain, SSL and PHP version.</Tabs.Content>
</Tabs.Root>Underline
Text tabs on a hairline with a 2px ink bar under the active tab. It reads like page navigation and suits long labels.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
</script>
<Tabs.Root value="overview" class="w-full max-w-2xl">
<Tabs.List variant="underline" class="w-full" aria-label="yoga-berger.de">
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="backups">Backups</Tabs.Trigger>
<Tabs.Trigger value="updates">Updates</Tabs.Trigger>
<Tabs.Trigger value="settings">Settings</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="overview" class="text-ink-2">
yoga-berger.de is online. WordPress 6.7, PHP 8.3.
</Tabs.Content>
<Tabs.Content value="backups" class="text-ink-2">Last backup today at 03:10.</Tabs.Content>
<Tabs.Content value="updates" class="text-ink-2">All plugins are up to date.</Tabs.Content>
<Tabs.Content value="settings" class="text-ink-2">Domain, SSL and PHP version.</Tabs.Content>
</Tabs.Root>With counts
Put a Tabs.Count inside the trigger to show how many items wait in each queue. The active count turns ink.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
const queues = [
{
value: 'open',
label: 'Open',
count: 4,
text: 'Contact form on yoga-berger.de sends no emails.'
},
{
value: 'waiting',
label: 'Waiting for customer',
count: 2,
text: 'Jonas Weber asked for the new logo files.'
},
{ value: 'done', label: 'Done', count: 18, text: 'Mailbox info@yoga-berger.de was set up.' }
];
</script>
<Tabs.Root value="open" class="w-full max-w-2xl">
<Tabs.List variant="underline" class="w-full" aria-label="Support requests">
{#each queues as queue (queue.value)}
<Tabs.Trigger value={queue.value}>
{queue.label}
<Tabs.Count aria-label="{queue.count} requests">{queue.count}</Tabs.Count>
</Tabs.Trigger>
{/each}
</Tabs.List>
{#each queues as queue (queue.value)}
<Tabs.Content value={queue.value} class="text-ink-2">{queue.text}</Tabs.Content>
{/each}
</Tabs.Root>Vertical
Set orientation="vertical" on Tabs.Root for settings pages with a side list.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
</script>
<Tabs.Root value="account" orientation="vertical" class="w-full max-w-2xl">
<Tabs.List variant="underline" aria-label="Settings">
<Tabs.Trigger value="account">Account</Tabs.Trigger>
<Tabs.Trigger value="payment">Payment methods</Tabs.Trigger>
<Tabs.Trigger value="contracts">Contracts</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="account" class="text-ink-2">Laura Berger, laura@yoga-berger.de</Tabs.Content>
<Tabs.Content value="payment" class="text-ink-2">Direct debit, IBAN ending in 4410.</Tabs.Content>
<Tabs.Content value="contracts" class="text-ink-2"
>WordPress Hosting, renews on 1 March.</Tabs.Content
>
</Tabs.Root>Narrow screens
Pill and underline lists scroll sideways when they run out of room. The active tab scrolls into the middle; the page itself does not move.
<script lang="ts">
import * as Tabs from '@statix/ui/tabs';
</script>
<div class="w-full max-w-xs">
<Tabs.Root value="invoices">
<Tabs.List variant="pill" aria-label="Customer area">
<Tabs.Trigger value="start">Start</Tabs.Trigger>
<Tabs.Trigger value="websites">Websites</Tabs.Trigger>
<Tabs.Trigger value="email">E-Mail</Tabs.Trigger>
<Tabs.Trigger value="domains">Domains</Tabs.Trigger>
<Tabs.Trigger value="invoices">Invoices</Tabs.Trigger>
</Tabs.List>
</Tabs.Root>
</div>Guidelines
Do
- Keep labels to one or two words: "Overview", "Backups", "Settings".
- Use pill for the sections of a website, mailbox or domain. Use underline when labels are long or carry counts.
- Give Tabs.List an aria-label that names the object, for example the domain.
Don't
- Do not use tabs to move between pages. Use links in the nav bar instead.
- Do not hide content the customer needs to compare side by side behind different tabs.
- Do not mix two tab styles on one screen.
Accessibility
- Follows the WAI-ARIA tabs pattern: role="tablist", role="tab" with aria-selected and role="tabpanel" with aria-labelledby.
- Arrow keys move between tabs (left/right, or up/down when vertical), Home and End jump to the ends. Disabled tabs are skipped.
- Tabs activate on focus by default. Pass activationMode="manual" to Tabs.Root to require Enter or Space.
- Give a Tabs.Count an aria-label like "4 requests" when the number alone is unclear.
API reference
Tabs.Root
renders<div> and accepts its attributesHolds the selected value and the orientation.
| Prop | Type | Default |
|---|---|---|
value bind | string The selected tab. | – |
onValueChange | (value: string) => void Called when the selected tab changes. | – |
orientation | 'horizontal' | 'vertical' Layout and arrow-key direction. | 'horizontal' |
activationMode | 'automatic' | 'manual' automatic selects on focus, manual waits for Enter or Space. | 'automatic' |
loop | boolean Arrow keys wrap around. | true |
disabled | boolean Disables all tabs. | false |
ref bind | HTMLDivElement | null The root element. | – |
class | ClassValue Merged with the root classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="tabs" | Always present. |
data-orientation | "horizontal" or "vertical". |
Tabs.List
renders<div role="tablist"> and accepts its attributesWraps the triggers and sets the style for all of them.
| Prop | Type | Default |
|---|---|---|
variant | 'default' | 'pill' | 'underline' | 'line' Visual style. line is the shadcn name and renders as underline. | 'default' |
ref bind | HTMLDivElement | null The list element. | – |
class | ClassValue Merged with the variant classes; yours win. | – |
| Data attribute | Meaning |
|---|---|
data-slot="tabs-list" | Always present. |
data-variant | The current style. Triggers read it through the group/tabs-list group. |
Tabs.Trigger
renders<button role="tab"> and accepts its attributes| Prop | Type | Default |
|---|---|---|
value * | string The value this tab selects. | – |
disabled | boolean Skips and greys out the tab. | false |
ref bind | HTMLButtonElement | null The button. | – |
class | ClassValue Merged with the trigger classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="tabs-trigger" | Always present. |
data-state | "active" or "inactive". |
data-disabled | Present when disabled. |
Tabs.Count
renders<span> and accepts its attributesStatix addition. A small count badge inside a trigger. It turns ink on the active tab.
| Prop | Type | Default |
|---|---|---|
ref bind | HTMLSpanElement | null The badge. | – |
class | ClassValue Merged with the badge classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="tabs-count" | Always present. |
Tabs.Content
renders<div role="tabpanel"> and accepts its attributes| Prop | Type | Default |
|---|---|---|
value * | string Shown when this value is selected. | – |
ref bind | HTMLDivElement | null The panel. | – |
class | ClassValue Merged with the panel classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="tabs-content" | Always present. |
data-state | "active" or "inactive". |
tabsListVariants
The tailwind-variants function behind Tabs.List.