Segmented control
One choice among a few, as a Mac view switcher
Showing the list view.
Usage
import { SegmentedControl } from "@gpuixui/components/segmented-control";
const [view, setView] = useState("list");
<SegmentedControl
label="View"
value={view}
onValueChange={setView}
items={[
{ value: "list", label: "List", icon: "list" },
{ value: "board", label: "Board", icon: "grid" },
]}
/>;Composition
SegmentedControl (the muted track, one tab stop)
└── segment × n (the primitives' action; the chosen one raised)API
| Prop | Type | Default |
|---|---|---|
label | string — the group's accessible name | — |
items | { value, label, icon?, disabled? }[] | — |
value | string — the chosen segment | — |
onValueChange | (value: string) => void | — |
size | "sm" | "md" | "sm" |
Behaviour
- The arrow keys select as they move and stop at either end, skipping a disabled segment — a Mac segmented control's rule, not a tab list's. Focus follows the choice.
- Segments share the track's width equally.
The chosen segment
The chosen segment is the surface raised off the track. In a light theme that is the page's background;
in a dark theme the page is darker than the track, so it lifts the track colour toward white instead.
Keyboard
- Arrow LeftArrow Right
- selects the next or previous enabled segment, stopping at the ends
A segment's own activation is the primitives' action: a press selects it.
read from segmented-control.tsx
Edit this page on GitHubpackages/components/docs/segmented-control.mdx