datui
Color scheme

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

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 > tab with aria-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.
  • status is 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 with aria-current="page" for site sections instead of in-page panels.

API

Tabs

Horizontal tabs. Scrolls horizontally when the items overflow. Children are `TabsItem`s.

PropTypeDefaultDescription
classNamestring—
defaultValuestring—
layoutFillMode"auto" | "stretched" | "shrinked"auto`stretched` shares the width equally, `shrinked` sizes tabs to content. `auto`: stretched on compact widths.
modeTabsModedefault`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`.
scrollToSelectedbooleantrueScroll the selected tab into view when the selection changes.
scrollToSelectedInlineScrollLogicalPositionnearest
valuestring—

TabsItem

One tab of `Tabs`. In tablist mode pass `aria-controls` pointing at its panel.

PropTypeDefaultDescription
value (required)string—Identifies the tab inside `Tabs`.
afterReactNode—
beforeReactNode—
classNamestring—
disabledbooleanfalse
hrefstring—Navigation mode only: render a link.
selectedboolean—Force selection (navigation mode, or when the selection lives elsewhere).
statusReactNode—Counter or badge after the label. Announced after a space.