Select
Select is a form control that lets someone choose one option from a list.
<Select defaultValue="banana" items={labels}> <SelectTrigger placeholder="Pick one" /> <SelectContent> <SelectGroup> <SelectLabel>Fruit</SelectLabel> <SelectItem value="banana">Banana</SelectItem> </SelectGroup> </SelectContent></Select>Select lets someone pick one option from a list. The closed trigger shows the current choice, and pressing it opens a panel of options. Use it when there are too many options to show on the screen at once. When there are only a few, use a SegmentedControl or a RadioGroup, so people can see every option without opening anything. Use a Combobox when people need to type to filter a long list, and a Menu when the options are actions rather than a value.
The trigger is a button drawn like a field, with the same fill, border and height as a TextField, so the two sit side by side as the same kind of input. The panel is never narrower than the trigger, and when it opens, the chosen option sits over the trigger with the rest of the list above and below it.
Pass items, an object that maps each value to its label. The closed trigger uses it to show the chosen option's label, because the options themselves aren't rendered while the panel is closed. Without items, the trigger shows the raw value.
Select renders a hidden input, so name and required work in a form just as they do on a native select. Inside a Field, the FieldLabel names the trigger. Screen readers announce the trigger as a combobox and the panel as a listbox. The arrow keys move through the options, and typing a letter jumps to an option that starts with it.
The part names follow shadcn/ui's select (MIT).
- Menu when each item runs an action, and nothing stays chosen.
- Combobox when the list is long enough that people need to type to narrow it.
- Radio Group when there are only a few options and showing them all helps people compare.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Holding the choice
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | A <SelectTrigger> and a <SelectContent>. |
defaultOpen? | boolean | Whether the panel is open at the start, when the select controls it. |
defaultValue? | string | The value at the start, when the select controls its own value. |
disabled? | boolean | Turns off the whole control. |
items? | Record<string, React.ReactNode> | Maps each value to the label that the closed trigger shows. |
name? | string | The name of the field when a form is submitted. |
onOpenChange? | (open: boolean, details: SelectOpenChangeDetails) => void | Called when the panel opens or closes. |
onValueChange? | (value: string | null) => void | Called when the chosen value changes. |
open? | boolean | Whether the panel is open, when you control it. |
required? | boolean | Makes a value necessary before the form can submit, as on a native <select>. |
size? | "1" | "2" | "3" | "4" | Sets the size step of the trigger and the panel. |
value? | string | The chosen value, when you control it. |
SelectTrigger
The button that shows the current choice. It looks like a field, with the same fill, border and height, and a muted chevron at the end
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when the trigger sits over other content, such as an image. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
placeholder? | string | The text that the trigger shows, in a muted colour, while no value is chosen. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
It also takes every prop of a <button>.
Presenting the panel
SelectContent
The floating panel of options. It opens above the rest of the page, with the same theme as the trigger, and it is never narrower than the trigger
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The options: SelectItem elements, in SelectGroup elements with a SelectLabel if you need groups. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
It also takes every prop of a <div>.
Listing the options
SelectItem
One option. A tick in the accent colour marks the chosen option, and its space is kept on every row, so the text of all the options lines up
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The text of the option in the panel. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
disabled? | boolean | Turns off the option, so you can't choose it. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
value | string | The value of this option. |
Grouping into sections
SelectGroup
A set of related options. When a SelectLabel is inside it, screen readers use the label as the group's name
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The SelectItem options in the group, and one SelectLabel that names them. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
SelectLabel
A heading above a set of options. It starts at the edge of the rows, a little to the left of the option text, which leaves room for the tick, as in macOS
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The name of the options below it. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
readOnly— HTML doesn't support a read-only select, so there is no standard behaviour to follow. To show a value that can't change, display it asText, and add your own hidden input if the form still needs to send it.- A Separator inside the panel — The panel is a listbox, and a listbox may only contain options and groups, so a separator fails accessibility checks. Use
SelectGroupto divide the options instead. emphasisandtoneon the trigger — Loudness ranks actions, and no field in a form is more important than the one beside it. To show that a value is wrong, mark the field as invalid throughField.- A
SelectValuepart — The trigger shows the chosen value itself and accepts aplaceholderfor when nothing is chosen, so a separate part would have nothing to do. renderandchildrenon the trigger — The trigger's content is always the chosen value, and it must stay a real button so screen readers announce it as a combobox. Style the options and useitemsto control what the trigger shows.- Scroll arrows — The panel already scrolls with a wheel, a trackpad or the keyboard. Arrow buttons at the ends would only help a mouse user, so they aren't included.
multiple— Choosing several values changes how the trigger shows the value, how each option shows its state and what the form sends, so it is a different control. Use checkboxes in aFieldfor a short list.