Navigation
Tabs
Keyboard-navigable tab panels backed by Bits UI, controlled or uncontrolled.
<script>
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@codeatlasdev/ui";
</script>
<Tabs value="overview">
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="props">Props</TabsTrigger>
</TabsList>
<TabsContent value="overview">...</TabsContent>
<TabsContent value="props">...</TabsContent>
</Tabs>
Arrow keys move between tabs, Home and End jump to the first and last, and the panels use the tabpanel role. Each TabsTrigger and TabsContent pair must share a value.
Default
Three tabs with content panels.
The Tabs component uses Bits UI's accessible tab primitives. Arrow keys cycle through tabs, Home and End jump to the first and last.
Tabs accepts a value prop for controlled mode and onchange for change notifications. Uncontrolled mode works too.
Common uses: settings pages, detail views with several data categories, code and preview panes, and stepped forms.
Code
Controlled
The parent owns the active tab with bind:value.
Overview panel.
Props panel.
Examples panel.
Active tab: overview
Code
Tabs
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | – | Bindable active tab value. |
onchange | (v: string) => void | – | Fires when the active tab changes. |
children | Snippet | – | TabsList and TabsContent children. |
class | string | '' | Extra classes on the root. |
TabsTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | – | Required. Links the trigger to its TabsContent. |
disabled | boolean | false | Prevents selecting the tab. |
children | Snippet | – | Trigger label. |
class | string | '' | Extra CSS classes. |
TabsContent
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | – | Required. Shown while the matching trigger is active. |
children | Snippet | – | Panel content. |
class | string | '' | Extra CSS classes. |