Skip to Content
Getting startedFoundationsComponentsPackagesTools

Tabs

A tablist and the panel it controls, or a segmented mode switch.

Examples

Playground

The overview panel. Tab once more to reach it: the tablist is a single stop.

Appearance

A second appearance (haus#60), and it is a shape rather than a weight. `underline` stays the default so nothing existing moves. `segmented` exists because a two-way mode switch is not a set of sections. core's editor toggles between Write and Preview, and a row of underlined words does not say *these are the two states of one control* the way a filled segment does. It is deliberately **not** the shared `Appearance` union, which is `subtle | solid` and means fill weight on Badge and Toast. Reusing that name would put two unrelated meanings on one type.

underline
The overview panel.
segmented
The overview panel.

Size

Each size reads its label role whole: label-sm, label-md, label-lg.

sm
The overview panel.
md
The overview panel.
lg
The overview panel.

Content

A disabled tab, which the arrows skip, and labels of different lengths.

The overview panel.

Install

npx shadcn add @hipuku/tabs

Usage

import { Tabs } from '@/components/haus/components/Tabs'

<Tabs
  aria-label="Project"
  items={[
    { label: 'Overview', value: 'overview' },
    { label: 'Activity', value: 'activity' },
  ]}
  value={tab}
  onValueChange={setTab}
>
  {tab === 'overview' ? <Overview /> : <Activity />}
</Tabs>

API

Tabs also takes its element's own attributes and forwards its ref. className lands on the root and tabListClassName on the tablist.

PropTypeDescription
aria-labelstringDefines a string value that labels the current element.
itemsrequiredTabItem[]
valuerequiredstring
onValueChangerequired(value: string) => void
size"sm" | "md" | "lg"
appearance"underline" | "segmented"
tabListClassNamestringLands on the tablist rather than the wrapper, so the label a screen reader reads for the tab group is the one the caller wrote.
panelIdundefined

Appearances

underline is the default, for sections. segmented fills the selected tab inside a track, for a two or three way mode switch.

Rendering the panel yourself

Tabs renders the panel from children. When the panel has to sit elsewhere on the page, pass panelId and an id instead, and give your panel role="tabpanel", tabIndex={0} and aria-labelledby={tabIdFor(id, value)}, using the exported tabIdFor.

Accessibility

  • A name is required, as aria-label or aria-labelledby.
  • The tablist is one tab stop. The arrow keys move between tabs and wrap, Home and End jump, and disabled tabs are skipped. Selection follows focus.
  • Tab from the tablist moves into the panel.

On this page