Skip to content

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 / onChange take a key (or null), or an array of keys when multiple.
  • items with a render function as children, or SelectItems written out; disabledKeys disables options.
  • defaultOpen and onOpenChange, with open above, control the menu.
  • name and form for forms; validate and validationBehavior as in Text field; autoFocus, onFocus, onBlur.
  • placeholder, shown in the field when nothing is chosen; autoComplete for the hidden select browsers fill.

Do and don't

Do: Use a select for one choice from a long list: it takes less room than radio buttons or chips.
Don't: Don't hide two or three choices people should compare in a select: show them as radio buttons or chips.

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.