组件

Tabs

Index-divider tabs: the active one is lifted and filled with highlighter, and the pencil baseline breaks under it. Also a hairline `line` style with a blue felt underline, and vertical binder tabs. Radix behavior and roving focus are untouched.

安装

terminal
npx shadcn@latest add @wobko/tabs

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Account and password

Index-divider tabs: the active one is lifted and filled with highlighter, and the pencil baseline breaks under it. Arrow keys move between tabs, Home and End jump to the ends.

Line tabs with icons

`variant="line"` is a hairline with the active tab underlined in blue felt, wiped in from the reading side. Icons sit at 16 px in the same weight as the label; a disabled tab is skipped by the arrow keys.

Binder tabs

`orientation="vertical"`: tabs down a spine like binder dividers, the active one filled and open towards its page. ArrowUp and ArrowDown move between them.

Controlled, manual activation

`value` and `onValueChange` drive the tabs from outside; `activationMode="manual"` moves focus with the arrow keys and only opens a tab on Enter or Space, which suits panels that are slow to load.

Demo

Official `tabs-demo`: Account and Password tabs, each holding a Card with a small form. The tabs are index dividers standing on a pencil baseline; the active one is lifted and filled with highlighter. Arrow keys move between tabs, Home and End jump to the first and last.

API 参考

Tabs

The Radix Tabs root. Vertical tabs lay the list and the panel side by side.

属性类型默认值说明
value / defaultValue / onValueChangestring / string / (value: string) => void-Controlled and uncontrolled state.
orientation"horizontal" | "vertical""horizontal"Vertical draws binder tabs on a spine and moves with ArrowUp / ArrowDown.
activationMode"automatic" | "manual""automatic"Automatic opens a tab as focus reaches it; manual waits for Enter or Space.
dir"ltr" | "rtl"-Reading direction; the arrows and the drawings follow it.

TabsList

The `role="tablist"` row (or column). `tabsListVariants` is exported for consumers that style their own list.

属性类型默认值说明
variant"default" | "line""default"`default` = paper index tabs; `line` = hairline with the active tab underlined in blue felt.

TabsTrigger

A tab (Radix Trigger, a button). It hosts its own drawing: sketch and baseline at rest, felt outline on hover, highlighter fill when active, a blue ring on keyboard focus.

属性类型默认值说明
valuestring-Ties the tab to its TabsContent.
disabledbooleanfalseDashed pencil sketch, skipped by the arrow keys.
seedstring | number-Pins the hand. Default: derived from useId().

无障碍

  • Radix roles and keys: tablist, tab (aria-selected, aria-controls) and tabpanel (aria-labelledby). Left/Right (Up/Down when vertical, mirrored in RTL) move between tabs and, in automatic mode, open them; Home and End jump to the first and last; Tab goes on into the panel.
  • The drawn tab, baseline and underline are aria-hidden and pointer-events: none; the tab keeps a 36 px hit box (32 compact, 28 calm).
  • The active tab is told apart by fill and outline, not by hue alone. Inactive text is 4.6:1 on paper, active text 14:1.
  • Keyboard focus draws a blue felt ring around the tab. Windows high contrast replaces the drawing with a real outline. Reduced motion turns the lift and the underline wipe into instant changes.
  • The tab list keeps its shape in right-to-left layouts: the vertical spine moves to the other side and the drawings mirror.

源码

CLI 会复制进你项目的文件。

正在加载源码