Combobox
A text input that filters a list of options as you type.
MarkdownExamples
Basic
- Argentina
- Australia
- Brazil
- Canada
- Egypt
- France
- Germany
- Ghana
- India
- Japan
- Kenya
- Mexico
- Nigeria
- Norway
- Portugal
- South Africa
- Spain
- Sweden
- United Kingdom
- United States
Tags
With multiple, picks show as chips. With creatable, Enter on new text emits create so you can add it.
- vue
- nuxt
- css
- typescript
- accessibility
- ssr
Enter adds a new tag. Backspace removes the last.
Async options
Fetch matches as v-model:query changes, and set ignore-filter so your results show as they are. Set loading while a request runs.
- Ada Lovelace
- Alan Turing
- Grace Hopper
- Katherine Johnson
- Linus Torvalds
- Margaret Hamilton
API
| Prop | Type | Default |
|---|---|---|
optionsOptions to choose from. | SelectOption<T>[] | [] |
labelVisible label, linked to the input. | string | — |
hintHelp text under the control, announced as its description. | string | — |
error
| string | boolean | — |
placeholderInput placeholder. | string | — |
multiplePick several; | boolean | false |
creatableEnter on text matching no option emits | boolean | false |
optionalAppends the | boolean | false |
disabledDisables the control. | boolean | false |
filterCustom match for each option against the lower-cased query. By default, labels are ranked exact, then prefix, then substring. | ComboboxFilter<T> | — |
ignoreFilterShow | boolean | false |
loadingOptions are being fetched: shows the | boolean | false |
nameForm field name: submits the value with a native form, via hidden inputs. | string | — |
idId for the input; generated with | string | — |
modelValueThe selected value, or values with | T | T[] | — |
queryThe input's text. Bind it to fetch options as the user types. | string | "" |
| Event | Payload |
|---|---|
createEnter was pressed on text matching no option (with | [query: string] |
update:modelValue
| [value: T | T[] | undefined] |
update:query
| [value: string] |
| Slot | Props |
|---|---|
optionOption content. | { option: SelectOption<T>; selected: boolean; active: boolean; } |
chipEach selected value in | { option: SelectOption<T>; remove: () => void; } |
emptyShown when nothing matches. | { query: string; } |
createShown with | { query: string; } |
loadingShown while | — |
Types
export interface SelectOption<T extends SelectValue = SelectValue> {
label: string;
value: T;
disabled?: boolean;
}
export type ComboboxFilter<T extends SelectValue> = (
option: SelectOption<T>,
query: string,
) => boolean;
export type SelectValue = string | number;Copy codeStyling
- Parts
fieldfield-labelfield-optionalcombobox-controlcombobox-chipcombobox-chip-labelcombobox-chip-removecombobox-inputcombobox-popupcombobox-listboxcombobox-optioncombobox-option-labelcombobox-loadingcombobox-createcombobox-emptycombobox-statusfield-message- States
data-field-errordata-field-namedata-combobox-opendata-combobox-disableddata-combobox-activedata-field-tone
Keyboard
| Keys | Action |
|---|---|
| Typing | Filter, and open the list |
↓ / ↑ | Move between options, wrapping |
Alt + ↓ | Open without moving |
Enter | Select the active option, or create (with creatable) |
Escape | Close; press again to clear |
Backspace | With multiple and an empty input, remove the last chip |
Accessibility
- Focus stays in the input; screen readers follow the highlighted option through
aria-activedescendant. - While typing, a hidden status announces the number of matches, “No results”, or “Loading…”.
- Chips aren't in the tab order, so with
multiplethe picks are read as part of the input's description. - In single mode, leaving the input with unmatched text restores the selection.