Duolith docs

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

PropTypeDefaultMeans
labelstringThe tab list's accessible name.
tabs{ value: string; label: string; icon?: string; disabled?: boolean }[]The tabs, in order.
selectedstringbindable("")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

StateLooks like
chosenPrimary text and a 2px primary line under the tab.
pressedThe tab's background turns raised.
focusedThe focus outline on the tab, or on the panel.
disabledThe tab at 45% opacity; it cannot be chosen.

Accessibility

roletablist of tabs with aria-selected and aria-controls, over one tabpanel named by the chosen tab
nameThe label prop; each tab by its text.
focusOne Tab stop for the tab list, on the chosen tab (roving tabindex); the next Tab reaches the panel.
keyboardArrowRight 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>