Forms
Select
Choose one option from a list. Type-ahead, keyboard navigation, groups and descriptions — and form submission plus browser autofill through a hidden native select.
import { Select } from '@reactloom/ui';Examples
Basic
Disabled options are skipped by the keyboard.
import { Select } from '@reactloom/ui';
const countries = [
{ value: 'de', label: 'Germany' },
{ value: 'in', label: 'India' },
{ value: 'jp', label: 'Japan' },
{ value: 'br', label: 'Brazil' },
{ value: 'us', label: 'United States', disabled: true },
];
export default function Example() {
return (
<div style={{ width: '100%', maxWidth: 320 }}>
<Select label="Country" name="country" autoComplete="country" options={countries} placeholder="Choose a country" />
</div>
);
}Groups and descriptions
Used for reports and reminders.
import { Select } from '@reactloom/ui';
const timezones = [
{ label: 'Europe', options: [{ value: 'berlin', label: 'Berlin', description: 'UTC+1' }, { value: 'london', label: 'London', description: 'UTC+0' }] },
{ label: 'Asia', options: [{ value: 'kolkata', label: 'Kolkata', description: 'UTC+5:30' }, { value: 'tokyo', label: 'Tokyo', description: 'UTC+9' }] },
];
export default function Example() {
return (
<div style={{ width: '100%', maxWidth: 320 }}>
<Select label="Time zone" description="Used for reports and reminders." options={timezones} defaultValue="berlin" />
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
optionsrequired{ value, label, description?, icon?, disabled? } or { label, options }. | (SelectOption | SelectOptionGroup)[] | — |
label | ReactNode | — |
value / defaultValue | string | null | — |
onValueChange | (value: string | null) => void | — |
placeholder | string | 'Select…' |
name · autoCompleteNative form submission and autofill. | string | — |
description · error · required · disabledField wiring like Input. | | — |
size | 'sm' | 'md' | 'lg' | 'md' |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-disabled] | present when on |
[data-focus-visible] | present when on |
[data-invalid] | present when on |
[data-open] | present when on |
[data-placeholder] | present when on |
[data-size] | sm · md · lg |
Theme tokens it reads
--pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-focus --pl-color-border-input --pl-color-danger-border --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-color-fg-subtle --pl-control-height-lg --pl-control-height-md --pl-control-height-sm --pl-focus-ring-color --pl-focus-ring-width --pl-font-size-lg --pl-font-size-md --pl-font-size-sm --pl-radius-md --pl-shadow-xs
Accessibility
- Behaviour from React Aria: type-ahead on the closed trigger, arrow keys, Home/End, Escape.
- A hidden native select keeps forms, FormData and browser autofill working.
- The list renders in the top layer, so it is never clipped by scroll containers.
| Key | Action |
|---|---|
| Enter / Space / ↓ | Open |
| ↑ / ↓ | Move |
| Enter | Choose |
| Escape | Close |
| a–z | Type-ahead |
Usage guidelines
Do
- Use for 5–30 options.
Don’t
- Don’t use Select for 2–4 options — use RadioGroup or SegmentedControl.
- For long lists people search, use Combobox.