Skip to content

Multi-select ​

A searchable multi-select that keeps what you picked as removable chips inside the field.

Open in demo
Open in demo

Usage ​

Bind an array with v-model and pass options as FieldOption[]. The array holds values, not options, and values are compared as strings.

The picked options live inside the control as chips. A row of selectable pills would make the form's height a function of how many options exist, and could not be searched.

The popover stays open while you pick, because choosing several things is the point. Click the trigger again, or press Escape, to close it.

Examples ​

Nothing selected ​

With an empty array the control shows the placeholder and keeps a single field's height.

Disabled options ​

An option carrying disabled stays in the list and cannot be picked.

Disabled ​

disabled blocks the trigger. The chips stay readable, and their remove buttons go with the trigger.

API ​

Source: src/shared/components/common/SaMultiSelect.vue

Props ​

PropTypeDefaultDescription
modelValueArray<string | number>[]The selected values.
optionsFieldOption[]required{ label, value, disabled? }. A label that is a translation key is translated.
placeholderstring'field.selectPrompt'Shown while nothing is selected. The default renders as "Select".
searchPlaceholderstring'field.searchPrompt'The search box text. The default renders as "Search…".
emptyTextstring'field.nothingFound'Shown when the search matches nothing. The default renders as "Nothing found".
disabledbooleanfalseBlocks the trigger.
idstring—Put on the trigger, so a <Label for> points at it.
invalidbooleanfalseSets aria-invalid on the trigger.
requiredboolean—Sets aria-required on the trigger.
describedBystring—Sets aria-describedby on the trigger.

Emits ​

EventPayloadDescription
update:modelValuevalue: Array<string | number>Fires on select, on deselect and on removing a chip.

Slots ​

None.

Accessibility ​

  • The trigger is a button with role="combobox" and aria-expanded, and takes aria-invalid, aria-required and aria-describedby from the props of the same names.
  • Each chip's remove control is named "Remove <label>" and answers to Enter. It stops the click from reaching the trigger, so removing a chip does not also open the list.
  • Selected options carry a check in the list, so the state does not rest on color.
  • The list filters as you type, and ArrowUp, ArrowDown, Enter and Escape work as they do in a command list.