Skip to main content

Segmented

Segmented control for mutually exclusive options, ideal for view switchers.

Basic usage​

Basic usage
Current value: list

The first row is a controlled usage that shows the current value; the second row uses block to fill the container, and disabled: true inside an option object disables that single option; the third row uses disabled to disable the whole group. Options also accept a string shortcut:

import { useState } from 'react'
import { LhSegmented } from '@lh-ui/react'

export default function Demo() {
const [value, setValue] = useState('list')

return <LhSegmented value={value} onChange={setValue} options={['List', 'Card', 'Table']} />
}

LhSegmented Props​

PropDescriptionTypeOptionsDefault
valueControlled current value (plus's modelValue)string | number——
defaultValueUncontrolled default valuestring | number——
optionsOptions (string shortcut or object)LhSegmentedInput[]——
disabledDisable the whole groupboolean—false
blockFill the containerboolean—false
sxShorthand layout propsSxProps——

LhSegmented events​

EventDescriptionCallback signatureVue equivalent
onChangeSelected option changed (triggered by click and arrow keys)(value: string | number) => void@update:modelValue / @change
Accessibility

The root element is a role="radiogroup" and each option is a real focusable button (role="radio" + aria-checked). With roving tabindex only the focused stop is tabbable; the arrow keys move in four directions, skipping disabled options and wrapping around.

Styles​

import '@lh-ui/react/style/segmented'