Skip to content
Look

Shared with the landing page. Theme is the select beside this menu.

Segmented

Open .md
Live preview

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 { 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).

packages/ui/src/navigation/segmented/segmented.tsx