Navigation
Tabs
Horizontal tabs with an underline or pill style. Scrolls horizontally when items overflow and keeps the selected tab in view.
import { Tabs, TabsItem } from "datui";Examples
Tabs with panels
Give each TabsItem an id and aria-controls, and each panel role="tabpanel" with aria-labelledby.
Overview content
Activity content
Members content
Modes
default underlines; accent and secondary use pills. status shows a counter.
As navigation
role="navigation" renders links marked with aria-current.
Accessibility
- Follows the WAI-ARIA tabs pattern:
tablist>tabwitharia-selected; one Tab stop for the list. - Left/Right arrows move between tabs (reversed in right-to-left layouts), Home/End jump to the ends; moving focus selects the tab.
statusis separated from the label by a space so it is read as "Inbox 3", not "Inbox3".- Disabled tabs are skipped by the arrow keys and cannot be selected.
role="navigation"renders a<nav>of links/buttons witharia-current="page"for site sections instead of in-page panels.
API
Tabs
Horizontal tabs. Scrolls horizontally when the items overflow. Children are `TabsItem`s.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| defaultValue | string | — | |
| layoutFillMode | "auto" | "stretched" | "shrinked" | auto | `stretched` shares the width equally, `shrinked` sizes tabs to content. `auto`: stretched on compact widths. |
| mode | TabsMode | default | `default` underlines the selected tab; `accent` and `secondary` use pills. |
| onChange | ((value: string) => void) | — | |
| role | "navigation" | "tablist" | tablist | `tablist`: WAI-ARIA tabs with arrow-key focus; give each `TabsItem` an `aria-controls` and its panel `aria-labelledby`. `navigation`: a `<nav>` of links/buttons marked with `aria-current`. |
| scrollToSelected | boolean | true | Scroll the selected tab into view when the selection changes. |
| scrollToSelectedInline | ScrollLogicalPosition | nearest | |
| value | string | — |
TabsItem
One tab of `Tabs`. In tablist mode pass `aria-controls` pointing at its panel.
| Prop | Type | Default | Description |
|---|---|---|---|
| value (required) | string | — | Identifies the tab inside `Tabs`. |
| after | ReactNode | — | |
| before | ReactNode | — | |
| className | string | — | |
| disabled | boolean | false | |
| href | string | — | Navigation mode only: render a link. |
| selected | boolean | — | Force selection (navigation mode, or when the selection lives elsewhere). |
| status | ReactNode | — | Counter or badge after the label. Announced after a space. |