Skip to main content

Select

A dropdown for choosing one value from a fixed list. Use it when the value must come from a known set. When the user can enter any text, use Autocomplete.

Base
Custom component
Mantine
Import
{ Select } from '@multiconsult-group-products/design-system'
Source
src/components/Select/Select.tsx
src/components/Select/Select.module.css
src/themes/style-overrides/select.module.css
src/themes/style-overrides/combobox.module.css
Same name as Mantine's Select

Mantine's own Select turns the field into a text input when it is searchable. Import this one from the design system. See Keeping the import honest for a lint rule that prevents the wrong import.

Usage​

searchable
clearable
disabled
size
sm
md
lg
React
<Select label="Kategori" placeholder="Velg kategori" size="md" defaultValue="Bygg" searchable data={['Anlegg', 'Bygg', 'Elektro', 'Utomhus', 'VVS']} />

The field follows TextInput. The dropdown is shared with the other comboboxes. Hovered, keyboard-active and selected options use the raised surface colour, and a selected option under the pointer uses its hover colour.

Props​

Only what this component adds or removes versus Mantine's Select — read the full props table there.

PropertyTypeAllowed valuesDefaultDescription
data(string | SelectItem)[]——Options as strings or as objects with value, label and disabled. No groups.
searchableboolean—falseAdds a search field at the top of the dropdown. The field itself is never editable.
searchLabelstring—'Søk'Accessible name of the search field.
searchPlaceholderstring—'Søk'Placeholder of the search field.
nothingFoundMessageReactNode—'Ingen treff'Shown when the search matches no option.
clearableboolean—falseAdds a button that clears the selection.
clearLabelstring—'Tøm valg'Accessible name of the clear button.
allowDeselect———Not exposed. Choosing the selected option keeps it. Use clearable to empty it.
classNames———Not exposed.
styles———Not exposed.

Accessibility​

Give the field a label. A select with only a placeholder has no accessible name once a value is chosen. See Accessibility for what applies to every component.