Segmented
Loading example…
Exclusive selector for 2-4 options. Like Radix type="single", it uses the radiogroup role.
Pressing the selected item keeps it selected; pass allowDeselect to let it clear instead.
Import
Section titled “Import”import { Segmented } from "@jcsoftdev/ui/navigation";Single-component entry points tree-shake to just this component: @jcsoftdev/ui/navigation/segmented.
export const Default: Story = {};Source of the Storybook story.
| Prop | Type | Default | Description |
|---|---|---|---|
value |
string |
Controlled selected value; an empty string means nothing selected. | |
defaultValue |
string |
||
onValueChange |
((value: string) => void) |
||
disabled |
boolean |
false |
Disables every item. |
rovingFocus |
boolean |
true |
Set to false to put every item in the tab order instead of roving. Defaults to true. |
options |
SegmentedOption[] |
Items from data, rendered when no children are given. | |
block |
boolean |
false |
Full-width selector with equal-width, control-height items. |
allowDeselect |
boolean |
false |
Lets a second press on the selected item clear the selection. Defaults to false: the selected item stays selected. |
orientation |
"horizontal" | "vertical" |
||
dir |
"ltr" | "rtl" |
"ltr" |
|
loop |
boolean |
true |
* marks a required prop.
It also accepts the native props of the element or primitive it renders (for example className, id, aria-* and event handlers).
Storybook stories
Section titled “Storybook stories”- Default
- Deselectable
- Disabled
- Two Options
- One Item Disabled
- Controlled
- Narrow
- From Options
- Block Without Deselect
Source
Section titled “Source”packages/ui/src/navigation/segmented/segmented.tsx