Core components / Select
Select
Pick one value from a list. Pass options and it opens Ochre's own listbox as a tray, with descriptions for rich choices; pass <option> children and it's the browser's select, dressed on the same ladder.
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
Where your data is stored.
Pick who gets the invoices.
Installation
Examples
Rich select
A description under each option, such as permission levels.
Applies to every project in Northwind.
The browser's select
Placeholder, chosen, with an icon, and disabled: native keyboard and pickers.
In a form
Native selects inside Fields beside an Input, at the L size used for sign-up.
Used on invoices.
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| options | SelectOption[] | – | { value, label, description?, detail?, leading?, disabled? }. Turns on Ochre's listbox. |
| value / defaultValue | string | null | – | The chosen value; null shows the placeholder. Vue: v-model. |
| onValueChange | (value: string) => void | – | Runs when someone picks a different option. |
| placeholder | string | "Choose one" | Shown in the placeholder colour until something is chosen. |
| size | "s" | "m" | "l" | "xl" | "xxl" | "m" | 32 to 64 pixels high, matching Input and Button. Options grow to touch size from L. |
| leadingIcon | ReactNode | – | Icon at the start, in the muted icon colour. |
| invalid / disabled | boolean | – | Red border and halo; or greyed out. Field sets invalid for you when it has an error. |
| name | string | – | Submits the value with a form (a hidden input for the listbox). |
| variant / label / align | "default" | "inline", ReactNode, "start" | "end" | – | The borderless Inline select and its label; which edge the tray lines up with. |
| children | <option> elements | – | Without options: the browser's own select, with <optgroup> if you need groups. |
| useListbox, ListboxTray, ListboxOption | exports | – | The engine and parts, for building your own selects (Person, Status and Multi-select use them). |
Usage
Use it for
- Choosing one value from a known list: role, region, currency, permission level.
- Options with a description under each (Rich select), such as access levels.
- The native version for forms that must feel at home on phones.
Avoid
- Two to four options that should all stay visible: use a Segmented control or Radio group.
- Long lists people need to search: use a Combobox.
- Actions: use a Dropdown menu.