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
| Prop | Type | Default | Description |
|---|---|---|---|
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
| Key | Does |
|---|---|
| Tab | Moves to the selected tab, then into its panel |
| ArrowLeft / ArrowRight | Select the previous / next tab, wrapping around (ArrowUp / ArrowDown when vertical) |
| Home / End | First / last tab |
Accessibility
- Follows the ARIA tabs pattern:
tablist,tabwitharia-selectedandaria-controls, and a focusabletabpanel. Disabled tabs are skipped.
Generated from src/components/Tabs.tsx. Something wrong or missing? Open an issue.