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.
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
<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.
| Property | Type | Allowed values | Default | Description |
|---|---|---|---|---|
data | (string | SelectItem)[] | — | — | Options as strings or as objects with value, label and disabled. No groups. |
searchable | boolean | — | false | Adds a search field at the top of the dropdown. The field itself is never editable. |
searchLabel | string | — | 'Søk' | Accessible name of the search field. |
searchPlaceholder | string | — | 'Søk' | Placeholder of the search field. |
nothingFoundMessage | ReactNode | — | 'Ingen treff' | Shown when the search matches no option. |
clearable | boolean | — | false | Adds a button that clears the selection. |
clearLabel | string | — | '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.