Select
Select is an input control that allows users to choose one option from a list.
Select
is just a lightweight wrapper around a native HTML Select element.
Consider using Single Select Menu and/or Multi Select Menu as a consistently styled and more powerful alernative.
#
Importimport { Select } from '@volue/wave-react';
#
Examples#
Basic#
ControlledSelect
is a controlled component, meaning that React state drives its value. You need to provide value
and onChange
properties to "make it work".
#
With Form FieldSelect
should be clearly labeled so it's obvious to users what are they choosing. Optionally, you may want to connect helper text and/or validation feedback message to the select.
Thus it is recommended to wrap select inputs with Form Field to create a consistent set of form fields that are accessible to screen reader users.
#
PlaceholderYou must provide placeholder
text when the input does not have an initial value.
Provide a default selected option whenever possible. This reduces the interaction cost by saving the user time and clicks.
#
Disabled inputPass isDisabled
prop to the accompanying FormField
and it will cascade down to the select input.
You can also pass isDisabled
prop directly to Select
.
The component can show an option as disabled, by setting the disabled
property on the option.
#
SizesWave provides two Select
sizes ‐ medium
and small
, with the medium
size used by default. All sizes are aligned with sizes of other related components like Button or Text Input.
#
Size inheritanceSelect
automatically inherits size, when placed inside a FormField component.
#
ResponsiveSelect
supports responsive syntax for its size
property, which means you can change its size based on the viewport.
#
Multi-sizingWave provides applySizes
utility, which lets you specify size "scopes" within your app.
All selects within a scope will share the same size unless overwritten on a per-control basis.
#
GroupsGroup related options together, uses the optgroup element internally.
#
API ReferenceIn addition to the props below, you can pass all React.SelectHTMLAttributes
.
Prop | Type | Default |
---|---|---|
css | StitchesCss | No default value |
selectCss | StitchesCss | No default value |
isDisabled | boolean | No default value |
isReadOnly | boolean | No default value |
isRequired | boolean | No default value |
validationStatus | enum | No default value |
options * | (Option | Group<Option>)[] | No default value |
value | string | number | No default value |
onChange * | function | No default value |
placeholder | string | No default value |
size | enum | No default value |