Select
An exposed dropdown menu: a field that opens a menu of options. One or several choices, sections, a search for long lists, a sheet on phones.
import { Select, SelectItem, SelectSection, OptionPopover } from '@windmorph/react';Purpose
A select is M3's exposed dropdown menu in its read-only form: a field that opens a menu of options and shows the chosen one. Use it for one choice (or a few) from a short, known list, such as a sort order or a currency. For a long list, or options from a server, use an Autocomplete; for up to about five options that should all stay visible, a RadioGroup; for actions rather than a value, a Menu.
Options are SelectItems, optionally in SelectSections, identified by a React key, or built from items with a render function. Create them in a client component. name submits the chosen key with a form, through a hidden native select that browsers can autofill.
Selection, items and forms
Each of these props has its row on the API tab; here is how they work together.
selectionMode:"single"(default) or"multiple".value/defaultValue/onChangetake a key (ornull), or an array of keys when multiple.itemswith a render function as children, orSelectItems written out;disabledKeysdisables options.defaultOpenandonOpenChange, withopenabove, control the menu.nameandformfor forms;validateandvalidationBehavioras in Text field;autoFocus,onFocus,onBlur.placeholder, shown in the field when nothing is chosen;autoCompletefor the hidden select browsers fill.
Do and don't
When not to use
For a long list or options from a server use an Autocomplete; for up to about five options that should stay visible, a Radio group; for actions, a Menu.
See also
- Select on m3.material.io: Material's own guidelines, with anatomy and specs.
- Autocomplete: A field you type into, with a menu of matching options. Accent-insensitive filtering, input chips for several choices, server results.
- Radio group: A set of radio buttons for picking exactly one option; a Radio needs a RadioGroup.
- Menu: A temporary list of choices anchored to a trigger, with groups, selection, submenus and context menus, or a bottom sheet on phones.
- Text field: Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.