Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Core

Tabs

Tabs that switch between panels in place. Arrow keys move between tabs; only the selected tab is in the Tab order.

import { Tabs } from "@stylhero/ui";

Example

Code
import { Tabs, Text } from "@stylhero/ui";

function TabsExample() {
  return (
    <Tabs label="Build details" items={[
      { id: "parts", label: "Parts", content: <Text>CPU, GPU, memory and storage.</Text> },
      { id: "price", label: "Price history", content: <Text>Prices over the last 30 days.</Text> },
      { id: "reviews", label: "Reviews", content: null, disabled: true },
    ]} />
  );
}

Props

PropTypeDefaultDescription
items required TabItem[] -
defaultValue string -
label string - Accessible name for the tab list.
onValueChange (id: string) => void -
orientation "horizontal" | "vertical" "horizontal" "vertical" puts the tabs in a column on the left.
value string - Controlled selected tab id.
variant "line" | "pills" "line" "pills" uses a segmented look instead of an underline.

Also takes every <div> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.

Types

type TabItem = { id: string; label: ReactNode; content: ReactNode; disabled?: boolean };

Keyboard

KeyDoes
TabMoves to the selected tab, then into its panel
ArrowLeft / ArrowRightSelect the previous / next tab, wrapping around (ArrowUp / ArrowDown when vertical)
Home / EndFirst / last tab

Accessibility

  • Follows the ARIA tabs pattern: tablist, tab with aria-selected and aria-controls, and a focusable tabpanel. Disabled tabs are skipped.

Generated from src/components/Tabs.tsx. Something wrong or missing? Open an issue.