Skip to content
GitHub (opens in a new tab)

Tabs

Switch between related views in place.

stableMoleculecontracts/tabs.json

Preview

Tabs

Switch between related views in place. Line by default, or segmented, in lg, md, and sm, horizontal or as vertical side tabs. Tabs can carry an icon and a count, and scroll or fold into a More menu when they don’t fit. Not DocsNav. Not RadioGroup. Not TabsList or TabsTrigger cousins.

Master

Line tabs at medium size. Variants shows segmented, other sizes, vertical, icons and counts.

What’s shipping now and how this kit is positioned.

Usage

Use Tabs to switch related views in place. Keep labels short and avoid nesting tabs inside tabs.

Do's

  • Grouped settings or detail sections on one page
  • Two to five peer views sharing one context
  • Compact local switching such as preview and code
  • Page views joined to PageHeader through its tabs slot (size md, line)
  • Side tabs that switch panels in place inside one page, Card or Modal, such as a settings card (orientation="vertical")

Don'ts

  • Top-level app routes — use SideNav (product) or DocsNav (docs/catalog)
  • Mutually exclusive form values — use RadioGroup
  • Single panel content — use Section
  • Sections that are pages with their own URL — use SideNav (see the settings pattern)
<Tabs
  defaultValue="overview"
  size="md"
  variant="line"
  items={[
    { id: "overview", label: "Overview", content: "…" },
    { id: "docs", label: "Docs", content: "…" },
    { id: "api", label: "API", content: "…" },
  ]}
/>

Switch between related views in place. Line by default, or segmented, in lg, md, and sm; horizontal above the panel or vertical side tabs beside it. Tabs can carry an icon and a count, and scroll or fold into a More menu when they don't fit.

When to use

  • Grouped settings or detail sections on one page
  • Two to five peer views sharing one context
  • Compact local switching such as preview and code
  • Page views joined to PageHeader through its tabs slot (size md, line)
  • Side tabs that switch panels in place inside one page, Card or Modal, such as a settings card (orientation="vertical")

When not to use

  • Top-level app routes — use SideNav (product) or DocsNav (docs/catalog)
  • Mutually exclusive form values — use RadioGroup
  • Single panel content — use Section
  • Sections that are pages with their own URL — use SideNav (see the settings pattern)

What an agent reads

import { Tabs } from "agentic-ds-kit";
must
  • Tab buttons control tabpanels
  • Active tab indicated visually and with aria-selected
  • Roving tabindex with arrow keys: Left/Right (and Up/Down) when horizontal; Up/Down only when vertical. Home and End jump to the first and last tab
  • vertical: the tablist has aria-orientation="vertical" while it shows as a column; in the narrow fallback it is a horizontal tablist again, with horizontal keys
  • vertical: the selected tab has the start-edge bar and aria-selected, never colour alone
  • Disabled tabs stay visible and are not selectable
  • A count is read as part of the tab's name
  • The More menu trigger sits outside the tablist and lists hidden tabs as menu items
  • line: after the first placement the underline glides to the selected tab (transform only, a one-pixel bar scaled to the tab). segmented: the old thumb fades out while the new one fades in, in place. A panel mounts the first time its tab is shown and then stays mounted, hidden and inert (content-visibility), so its state and scroll survive a switch; the shown panel fades in, opacity only. No motion under prefers-reduced-motion
defaults
  • size md
  • variant line
  • overflow scroll
  • activation automatic
  • orientation horizontal
  • ariaLabel Tabs
  • fill false
stops if
  • Do not invent TabsList, TabsTrigger, or TabsContent cousins
  • Do not use raw hex
  • Do not use Tabs for main app navigation — use SideNav (product) or DocsNav (docs/catalog)
  • Do not nest tabs inside tabs
  • Do not colour a tab or its count to show status; the number says it
  • Do not use Tabs to change a value inside one view — use SegmentedControl
  • Do not use vertical Tabs as page or app navigation, and do not put them beside a SideNav sub-nav for the same sections

From contracts/tabs.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
itemsarrayYes—icon sits before the label. count renders as a neutral kit Count after the label and is part of the tab's name; never show a count by colour alone.
valuestringNo——
defaultValuestringNo——
onChangefunctionNo——
sizesm | md | lgNomd—
variantline | segmentedNolinesegmented uses the SegmentedControl track: tray fill, 2px inset, thumb radius nested inside the track. Use segmented for values that change data inside one view; line for page or panel views.
overflowscroll | moreNoscrollscroll: one line that scrolls sideways when the tabs don't fit (touch, trackpad and arrow keys). more: the tabs that fit, then a More menu (kit DropdownMenu, KitLabels moreTabs) with the rest. The selected tab always stays in the row.
activationautomatic | manualNoautomaticautomatic: arrow keys select the tab they land on. manual: arrow keys move focus, Enter or Space selects. Use manual when a panel is slow to load.
orientationhorizontal | verticalNohorizontalhorizontal: the tab list sits above the panel. vertical: side tabs, the list in a column on the start side (--layout-sidebar wide, a hairline track with a bar on the selected tab) and the panel beside it. Vertical is always the line look (variant is ignored) and ignores overflow="more": the column grows downwards. When the Tabs is narrower than 40rem (the --grid-breakpoint-sm value) the list falls back to the horizontal row that scrolls sideways, above the panel. Tabs stretch to the column; a count sits at the end of the row.
ariaLabelstringNoTabs—
fillbooleanNofalseThe panel takes the height left under the tab list and its child stretches to it, for a full-height tab such as Chat embedded. Tabs needs a height or a flex/grid slot from its host.
  • Component
    →

    SideNav

    Product side nav: brand header, icon items, optional badges, closeable; variant single (one column that closes to an icon rail) or rail-subnav (a fixed icon rail plus a SideNav.SubNav column with the picked parent's rows).

  • Component
    →

    DocsNav

    Docs and catalog sidebar only: title, grouped text-only links, optional decorative icons and muted counts on group and subgroup headers only, an active page pill and optional footer links.

  • Component
    →

    RadioGroup

    Choose exactly one option from a small visible set.

  • Component
    →

    Section

    Grouped page block with optional heading, description, and actions.