Tabs
In-page tabs: a row of tabs over one panel that shows the chosen tab's content. Not the app's navigation tab bar, which belongs to routing.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The tab list's accessible name. | |
tabs | { value: string; label: string; icon?: string; disabled?: boolean }[] | The tabs, in order. | |
selected | string | bindable("") | The chosen tab's value. When it names no usable tab (none, or a disabled one), the first usable tab is shown and its value is written back, so a bound value always matches the tab list. Bind it with bind:selected={name}. |
Children
The panel's content. Show the chosen tab's content with <show when={selected === "..."}>; the panel is named by the chosen tab (aria-labelledby).
States
| State | Looks like |
|---|---|
chosen | Primary text and a 2px primary line under the tab. |
pressed | The tab's background turns raised. |
focused | The focus outline on the tab, or on the panel. |
disabled | The tab at 45% opacity; it cannot be chosen. |
Accessibility
| role | tablist of tabs with aria-selected and aria-controls, over one tabpanel named by the chosen tab |
| name | The label prop; each tab by its text. |
| focus | One Tab stop for the tab list, on the chosen tab (roving tabindex); the next Tab reaches the panel. |
| keyboard | ArrowRight and ArrowLeft move to the next or previous usable tab and show it at once (automatic activation), wrapping at the ends and skipping disabled tabs; Home and End go to the first and last. Enter or Space on a tab chooses it. |
Theme tokens
color.border color.muted color.primary color.raised space.3 radius.sm text.label
Example
<Tabs label="Details" tabs={sections} bind:selected={section}><show when={section === "menu"}>...</show></Tabs>