Captain UI

Tabs

An ink block slides under the labels and swaps their colour exactly at its edge, stretching the way it travels. The panel slides in from the same side.

npx shadcn@latest add https://captain-ui.vercel.app/r/tabs.json
  • app/api/webhooks/stripe/route.ts+28−11
  • lib/billing/idempotency.ts+9−2
  • tests/webhooks.test.ts+5−4

Usage

import { Tabs } from "@/components/ui/tabs"

<Tabs
  aria-label="Pull request"
  items={[
    { value: "overview", label: "Overview", content: <Overview /> },
    { value: "changes", label: "Changes", content: <Changes /> },
  ]}
/>

Props

PropTypeDefaultWhat it does
items{ value: string; label: ReactNode; content: ReactNode; disabled?: boolean }[]The tabs and their panels.
valuestringControlled value.
defaultValuestringitems[0].valueInitial tab when uncontrolled.
onValueChange(value: string) => voidCalled on click or arrow key.
aria-labelstringNames the tab list.
panelClassNamestringClasses for the panel area.

Keyboard

← →
Previous / next tab
Home / End
First / last tab
Tab
Into the panel

Accessibility

  • role=tablist, tab and tabpanel, with aria-selected, aria-controls and aria-labelledby.
  • Roving tabindex with automatic activation, as the WAI-ARIA tabs pattern describes.
  • The ink copy of the labels is aria-hidden, so each label is read once.