Select
A single or multiple choice from a dropdown.
MarkdownExamples
Basic
- LagosUTC+1
- LondonUTC+0
- New YorkUTC−5
- TokyoUTC+9
- SydneyUTC+10
Multiple
- Bug
- Feature
- Docs
- Question
API
| Prop | Type | Default |
|---|---|---|
optionsOptions to choose from. | SelectOption<T>[] | [] |
error
| string | boolean | — |
placeholderShown when nothing is selected. | string | "Select an option" |
multipleAllow several selections; | boolean | false |
optionalAppends the | boolean | false |
disabledDisables the control. | boolean | false |
labelVisible label, linked to the control. | string | — |
hintHelp text under the control, announced as its description. | string | — |
nameForm field name: submits the value with a native form, via hidden inputs. | string | — |
idId for the control; generated with | string | — |
modelValueThe selected value, or values with | T | T[] | — |
| Event | Payload |
|---|---|
update:modelValue
| [value: T | T[] | undefined] |
| Slot | Props |
|---|---|
valueTrigger content, replacing the selected label or placeholder. | { selected: SelectOption<T>[]; placeholder: string; } |
optionOption content. | { option: SelectOption<T>; selected: boolean; active: boolean; } |
chevronReplaces the trigger's chevron. | — |
checkReplaces the selected option's check mark. | — |
Types
export interface SelectOption<T extends SelectValue = SelectValue> {
label: string;
value: T;
disabled?: boolean;
}
export type SelectValue = string | number;Copy codeStyling
- Parts
fieldfield-labelfield-optionalselect-controlselect-triggerselect-valueselect-chevronselect-listboxselect-optionselect-option-checkselect-option-labelfield-message- States
data-field-errordata-field-namedata-select-opendata-select-errordata-select-placeholderdata-select-activedata-field-tone
Keyboard
| Keys | Action |
|---|---|
↓ / ↑ | Open, then move between options |
Enter / Space | Open, or select the active option |
Home / End | First / last option |
| Any letter | Jump to an option by label; repeat a letter to cycle |
Tab | Keep the active option and close |
Escape | Close |
Accessibility
- Focus stays on the trigger; the active option is set with
aria-activedescendant.