Segmented Control
Switches a setting between a few options.
Installation
pnpm dlx shadcn@latest add @paneui/segmented-controlUsage
Composition
Examples
Tabs or segmented control?
Use Tabs when the options switch panels of content. Use a segmented control when they change a value, like a billing cycle or theme. It is a radio group, so arrow keys move the selection.
Motion
Under reduced motion the thumb moves instantly.
API Reference
Built on the Radio Group primitive. Only the props this library adds or changes are listed; everything else passes through.
SegmentedControl
Also accepts every prop of RadioGroup.
- value
- string
- Controlled value.
- defaultValue
- string
- Initial value.
- onValueChange
- (value: string) => void
- Called with the new value.
- size= "default"
- "xs" | "sm" | "default" | "lg"
- Outer height 24 / 28 / 32 / 36px, the Button heights; items are 4px shorter.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Controlled value. |
| defaultValue | string | — | Initial value. |
| onValueChange | (value: string) => void | — | Called with the new value. |
| size | "xs" | "sm" | "default" | "lg" | "default" | Outer height 24 / 28 / 32 / 36px, the Button heights; items are 4px shorter. |
SegmentedControlItem
Also accepts every prop of Radio.Root.
- value*
- string
- This option's value.
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string | — | This option's value. |