Navigation
Tabs
Keyboard-navigable tab panels with roving focus, 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 focusing a tab selects it (automatic activation). Disabled tabs are skipped. The panels use the tabpanel role and are focusable. Each TabsTrigger and TabsContent pair must share a value. Tabs is horizontal only.
Default
Three tabs with content panels.
The Tabs component implements the WAI-ARIA tabs pattern. 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.
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 by click or keyboard. |
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. |
TabsList
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | – | The `TabsTrigger` elements. |
class | string | '' | Extra CSS classes. |