Skip to content

components/Segmented

import { … } from 'zidane-ui'ui/src/components/Segmented.tsx

Segmented md
Segmented sm, one disabled
TabPill + CountBadge in a track

Components#

SegmentedComponent#

Renders a track of mutually exclusive choices; the chosen one is the raised chip. It is a radio group with one tab stop on the checked item. Arrow keys, Home and End move the selection to the next enabled option.

TypeScript
function Segmented<T extends string>(props: SegmentedProps<T>): Element
Type parameters
NameTypeDescription
Textends string
Parameters
NameTypeDescription
propsSegmentedProps<T>

Component props.

Element
Segmented props
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the radio group.

className?string

Extra classes on the track.

onChange(v: T) => void

Called with the new value when an option is picked by click or keyboard.

optionsreadonly SegmentedOption<T>[]

The choices, in order.

size?'sm' | 'md''md'

Item height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

valueT

The value of the selected option.

ui/src/components/Segmented.tsx:54

Interfaces#

SegmentedOptionInterface#

One choice of a Segmented control.

TypeScript
interface SegmentedOption<T extends string>
SegmentedOption type parameters
NameTypeDescription
Textends string
SegmentedOption properties
NameTypeDescription
disabled?boolean

Grey the item out and skip it in keyboard navigation.

icon?string

Icon class shown before the label.

labelReactNode

Content of the item.

title?string

Native tooltip of the item.

tooltip?ReactNode

The kit's tooltip under the item, for a choice that needs a sentence. Replaces title.

valueT

The value reported to onChange when this option is picked. Unique among the options.

ui/src/components/Segmented.tsx:11

SegmentedPropsInterface#

Props for Segmented.

TypeScript
interface SegmentedProps<T extends string>
SegmentedProps type parameters
NameTypeDescription
Textends string
SegmentedProps properties
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the radio group.

className?string

Extra classes on the track.

onChange(v: T) => void

Called with the new value when an option is picked by click or keyboard.

optionsreadonly SegmentedOption<T>[]

The choices, in order.

size?'sm' | 'md''md'

Item height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

valueT

The value of the selected option.

ui/src/components/Segmented.tsx:27