Skip to main content

Select

A dropdown selector with controlled / uncontrolled modes, keyboard navigation, and clearing.

Basic usage​

Controlled selection

Current value: (not selected)

import { useState } from 'react'
import { LhSelect } from '@lh-ui/react'
import type { LhSelectOption } from '@lh-ui/react'

const options: LhSelectOption[] = [
{ label: 'Ink', value: 'ink' },
{ label: 'Danqing', value: 'danqing' },
{ label: 'Blank', value: 'blank' },
{ label: 'Gongbi', value: 'gongbi' },
]

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

return (
<LhSelect
value={value}
options={options}
placeholder="Select a style"
onChange={(val) => setValue(val as string)}
/>
)
}

Select Props​

PropDescriptionTypeOptionsDefault
valueControlled valueunknown——
defaultValueUncontrolled default valueunknown——
optionsOption listLhSelectOption[]—[]
placeholderPlaceholderstring—Locale pack fallback
disabledWhether to disableboolean—false
clearableWhether to be clearableboolean—false
sizeSize'large' | 'middle' | 'small'—Follows ConfigProvider
nameNative name attributestring——
ariaLabelAccessibility labelstring——
placementDropdown placementLhPlacement—'bottom-start'
themeVarsComponent-level theme variablesRecord<string, string>——
sxShorthand layout propsSxProps——

LhSelectOption​

PropDescriptionType
labelOption display textstring
valueOption valueunknown
disabledDisable this optionboolean

Select events​

EventDescriptionCallback signatureVue equivalent
onChangeEmitted on selection (two arguments: the value and the option object)(value: unknown, option: LhSelectOption | undefined) => void@change
onClearEmitted when cleared() => void@clear

Keyboard interaction​

When expanded: ArrowUp / ArrowDown highlight options (skipping disabled ones), Enter selects, and Escape collapses. The trigger is role="combobox", the panel is role="listbox", options are role="option", and aria-activedescendant tracks the highlight.

ref​

forwardRef<HTMLDivElement> — the trigger root element. LhSelectInstance exposes open() / close() / focus().

Styles​

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