Segmented Button
Two to five related options in one connected control. Use it to switch a view or set a filter: choices that apply right away, with no submit step.
Install
npx shadcn@latest add @nelumbo/segmented-buttonSingle select
Exactly one option stays selected, like a radio group. The check mark grows in on the selected segment; arrow keys move between options.
Showing the week view.
Multiple select
Any combination, including none. With an icon, the check mark replaces the icon instead of adding width, so the segments don't shift.
2 filters on
Sizes and options
Usage
<SegmentedButton type="single" value={view} onValueChange={setView} aria-label="Calendar view"> <SegmentedButtonItem value="day">Day</SegmentedButtonItem> <SegmentedButtonItem value="week">Week</SegmentedButtonItem></SegmentedButton>Props
| Prop | Type | Default | Notes |
|---|---|---|---|
type | "single" | "multiple" | required | Single keeps one option selected |
value / defaultValue | string | string[] | Matches type | |
onValueChange | (value) => void | ||
size | "sm" | "default" | "lg" | "default" | 32, 40, 48 px |
aria-label | string | Name the group for screen readers | |
Item: icon | IconName | The check replaces it when selected | |
Item: check | boolean | true | Turn off the check mark |