pro-ui

Select

Accessible dropdown select with keyboard navigation. Built on React Aria.

Import

import { Select } from '@dangbt/pro-ui'

Basic usage

<Select
  label="Role"
  placeholder="Select a role"
  options={[
    { value: 'admin', label: 'Administrator' },
    { value: 'editor', label: 'Editor' },
    { value: 'viewer', label: 'Viewer (read-only)' },
  ]}
/>

Controlled

const [value, setValue] = useState('editor')
 
<Select
  label="Role"
  value={value}
  onChange={(v) => setValue(v)}
  options={options}
/>

With error

<Select
  label="Country"
  options={countries}
  errorMessage="Please select a country"
/>

Props

PropTypeDefaultDescription
labelstringSelect label
placeholderstringPlaceholder when no value selected
options{ value: string; label: string }[]Options list
valuestringControlled value
onChange(value: string) => voidCalled on selection
errorMessagestringError state text
isDisabledbooleanDisable the select

On this page