Segmented Pill
betaA segmented control whose bright thumb slides to the chosen option and stretches elastically in transit.
- Forms
- 1 file
- 2 npm packages
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add segmented-pillnpm packages installed: class-variance-authority, radix-ui.
import { SegmentedPill } from "@/components/ui/segmented-pill";Default
Demo
<SegmentedPill>
| Prop | Type | Default |
|---|---|---|
defaultValueInitial selection when uncontrolled. Defaults to the first option. | string | — |
onValueChange | (value: string) => void | — |
optionsThe segments, as labels or | (string | SegmentedPillOption)[] | ["Day", "Week", "Month"] |
size | "sm" | "md" | "lg" | "md" |
valueControlled selection. | string | — |
Every prop of Radix UI’s RadioGroup.Root, plus className.
Built on the Radix radio group: role="radiogroup" with one role="radio" per segment, roving focus, and arrow keys that move and select (mirrored in right-to-left layouts), with a visible focus ring on the focused segment. Name the group with aria-label or aria-labelledby. The sliding thumb is aria-hidden; the selected segment is also marked by its text colour against the thumb. Under reduced motion the thumb jumps without stretching.
8/8
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — does not apply
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — does not apply
- No fixed widths — passes