Built on Radix UI Select
Select
A custom-styled listbox with groups, separators and disabled options. It submits natively inside forms.
Playground
import { ChibiSelect, ChibiSelectItem } from '@chibi-ui/react/select';
<ChibiSelect label="Favourite flavour" placeholder="Pick a flavour">
<ChibiSelectItem value="strawberry">Strawberry</ChibiSelectItem>
<ChibiSelectItem value="peach">Peach</ChibiSelectItem>
<ChibiSelectItem value="matcha">Matcha</ChibiSelectItem>
</ChibiSelect>Import
import {
ChibiSelect,
ChibiSelectItem,
ChibiSelectGroup,
ChibiSelectLabel,
ChibiSelectSeparator,
} from '@chibi-ui/react/select';Examples
<Controller
control={control}
name="flavour"
render={({ field }) => (
<ChibiSelect
label="Flavour"
placeholder="Pick one"
error={errors.flavour?.message}
value={field.value}
onValueChange={field.onChange}
onBlur={field.onBlur}
ref={field.ref} // lets RHF focus the trigger on error
name={field.name}
>
<ChibiSelectItem value="strawberry">Strawberry</ChibiSelectItem>
<ChibiSelectItem value="matcha">Matcha</ChibiSelectItem>
</ChibiSelect>
)}
/>Accessibility
- The trigger is a labelled combobox button. ref points at it, so react-hook-form can focus it when validation fails.
- Typeahead plus arrow, Home and End keys. Disabled options are skipped.
- The highlighted option gets an outline as well as a tint, so it meets non-text contrast.
- A hidden native <select> mirrors the value, so plain form submission works.
API reference
ChibiSelect
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | โ | Visible label, associated with the control. |
| description | ReactNode | โ | Helper text, linked via aria-describedby. |
| error | ReactNode | โ | Error message (e.g. errors.x?.message). Any truthy value sets aria-invalid; true marks invalid without a message. |
| containerClassName | string | โ | Class for the wrapper holding label, control and messages. |
| placeholder | ReactNode | โ | Shown when empty. |
| value / defaultValue | string | โ | Controlled / uncontrolled value. |
| onValueChange | (value: string) => void | โ | Selection callback. |
| name / required / disabled | โฆ | โ | Native form semantics. |
| size | 'sm' | 'md' | 'lg' | 'md' | Trigger height. |
| ref | Ref<HTMLButtonElement> | โ | Forwarded to the trigger. |