WlMultiSelect
Appearance
Full example
<script setup lang="ts">
import { WlMultiSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref(["design", "code"]);
const options = computed(() => [{
label: "Areas",
items: [
{ label: "Design", value: "design", disabled: false },
{ label: "Development", value: "code", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlMultiSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
show-select-all
filter
display="chip"
aria-label="Areas"
/>
</div>
</template>Selection
Full example
<script setup lang="ts">
import { WlMultiSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref(["design", "code"]);
const options = computed(() => [{
label: "Areas",
items: [
{ label: "Design", value: "design", disabled: false },
{ label: "Development", value: "code", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlMultiSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
show-select-all
filter
display="chip"
aria-label="Areas"
/>
</div>
</template>States
Full example
<script setup lang="ts">
import { WlMultiSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref(["design", "code"]);
const options = computed(() => [{
label: "Areas",
items: [
{ label: "Design", value: "design", disabled: false },
{ label: "Development", value: "code", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlMultiSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
show-select-all
filter
display="chip"
aria-label="Areas"
/>
</div>
</template>Chips, filter and summary
Multiple selection with a filter, removable chips and a comma summary, sizes, states and clearing the array.
Chips, filter and counter
Enter toggles the selected item; the list stays open for the next selection. Escape closes it.
Sizes and states
Selected: 2. Values: design, code.
5,000 options
Set virtual to window a large option list. Options and group headings use the same fixed height, and keyboard navigation continues through the full filtered list.
Full example
<script setup lang="ts">
import { WlButton, WlField, WlMultiSelect } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<string[]>(["design", "code"]);
const options = [{ id: "design", label: "Design" }, { id: "code", label: "Development" }, { id: "docs", label: "Documentation" }, { id: "qa", label: "Checks" }];
const largeOptions = computed(() => Array.from({ length: 5000 }, (_, index) =>
["Record", index + 1].join(" ")
));
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlMultiSelect">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Chips, filter and counter" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
id="docs-multi-chips"
v-slot="{ id, ariaDescribedby }"
label="Areas with a filter"
hint="Type a name in the filter; selected chips can be removed individually."
><WlMultiSelect
:id="id"
v-model="selected"
:options="options"
option-label="label"
option-value="id"
display="chip"
filter
:aria-describedby="ariaDescribedby"
placeholder="Choose areas"
/></WlField>
<WlField id="docs-multi-counter" v-slot="{ id }" label="Selected areas"><WlMultiSelect
:id="id"
v-model="selected"
:options="options"
option-label="label"
option-value="id"
display="comma"
:max-selected-labels="1"
placeholder="Choose areas"
/></WlField>
</div>
<p class="wl-text-small wl-text-muted">{{ "Enter toggles the selected item; the list stays open for the next selection. Escape closes it." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Sizes and states" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
v-for="size in ['sm', 'md', 'lg'] as const"
:id="`docs-multi-${size}`"
:key="size"
v-slot="{ id }"
:label="`${'Areas, '}${size}`"
><WlMultiSelect
:id="id"
v-model="selected"
:size="size"
:options="options"
option-label="label"
option-value="id"
/></WlField>
<WlField id="docs-multi-compact" v-slot="{ id }" label="Compact multiselect"><WlMultiSelect
:id="id"
v-model="selected"
density="compact"
:options="options"
option-label="label"
option-value="id"
/></WlField>
<WlField
id="docs-multi-invalid"
v-slot="{ id, ariaDescribedby, invalid }"
label="At least one area"
:error="selected.length ? undefined : 'Choose at least one area.'"
><WlMultiSelect
:id="id"
v-model="selected"
:options="options"
option-label="label"
option-value="id"
:invalid="invalid"
:aria-describedby="ariaDescribedby"
placeholder="Choose areas"
/></WlField>
<WlField id="docs-multi-disabled" v-slot="{ id }" label="Unavailable multiselect"><WlMultiSelect
:id="id"
:model-value="['design']"
:options="options"
option-label="label"
option-value="id"
display="chip"
disabled
/></WlField>
</div>
<WlButton size="sm" @click="selected = []">{{ "Clear areas" }}</WlButton>
<p class="wl-text-small" role="status">{{ "Selected:" }} {{
selected.length
}}{{ ". Values:" }} {{ selected.join(', ') || "none" }}.</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "5,000 options" }}</h3>
<WlMultiSelect
aria-label="5,000 options"
:options="largeOptions"
virtual
filter
display="chip"
:max-selected-labels="3"
/>
<p class="wl-text-small wl-text-muted">{{ "Set virtual to window a large option list. Options and group headings use the same fixed height, and keyboard navigation continues through the full filtered list." }}</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: WlMultiSelectModel<Array of values from optionValue; without it, TOption[]. Defaults to [].
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
virtual | WlVirtualOptions | false | — |
options | readonly TOption[] | [] | Readonly TOption list; selected value type is determined by optionValue. |
optionLabel | WlOptionLabel< | Not set | Label field name or (option) => string function. |
optionValue | TResolver | Not set | TOption key or (option: TOption) => TValue function; determines model array type. |
placeholder | string | Not set | Placeholder. |
invalid | boolean | false | Error state. |
disabled | boolean | false | Disables the field. |
size | WlSizeSm | "md" | Field size. |
density | WlDensity | "default" | Density. |
filter | boolean | false | Filter field inside the list. |
display | WlMultiSelectDisplay | "comma" | comma — comma-separated labels; chip — individual chips. |
maxSelectedLabels | number | Not set | Number of labels shown before a count replaces them. Only for display="comma". |
motion | boolean | Inherits WlConfig.motion | List animation; defaults to WlConfig.motion (true). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
optionDisabled | WlOptionDisabled< | Not set | Option field or predicate identifying disabled options. |
optionKey | WlOptionKeyResolver< | Not set | Stable option field or key resolver; keeps rendered option state with its data. |
optionGroupLabel | WlOptionLabel< | Not set | Resolve the visible label of an option group. |
optionGroupChildren | TGroupChildren | Not set | Resolve the readonly child options of a group descriptor. |
showSelectAll | boolean | false | Show the action for toggling all eligible filtered options. |
loading | boolean | false | Indicate pending work supplied by the application. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | WlMultiSelectModel< | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
option | option?(props: { option: Option; index: number; selected: boolean; active: boolean }): unknown; | Option scope: { option, index, selected, active }. |
value | value?(props: { options: Option[]; placeholder: string | | Selected values scope: { options, placeholder }. |
chip | chip?(props: { option: Option; remove: () => void }): unknown; | Selected chip scope: { option, remove }. |
empty | empty?(props: Record< | Content shown when no options match. |
header | header?(props: Record< | Content before the option list. |
footer | footer?(props: Record< | Content after the option list. |
optiongroup | optiongroup?(props: { group: TOption; label: string }): unknown; | Custom option-group heading; receives the descriptor and resolved label. |
loading | loading?(props: Record< | Content displayed while consumer-provided work is pending. |
selectall | selectall?(props: { checked: boolean; indeterminate: boolean; toggle: () => void; disabled: boolean }): unknown; | Custom select-all content with aggregate selection state and a toggle action. |
Pass-through: pt
Sections WlMultiSelect are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-multiselect | The root section in WlConfig.pt.multiselect configuration. |
labelContainer | div.wl-multiselect__label-container | The labelContainer section in WlConfig.pt.multiselect configuration. |
chipItem | span.wl-multiselect__chip | The chipItem section in WlConfig.pt.multiselect configuration. |
chip.root | span.wl-multiselect__chip | Main element of the component. |
chip.label | span.wl-multiselect__chip-label | Visible component label. |
chip.removeIcon | button.wl-multiselect__chip-remove | Button that removes the associated value or file. |
label | span.wl-multiselect__label | The label section in WlConfig.pt.multiselect configuration. |
hiddenInput | input | The hiddenInput section in WlConfig.pt.multiselect configuration. |
dropdown | span.wl-multiselect__dropdown | The dropdown section in WlConfig.pt.multiselect configuration. |
dropdownIcon | span.wl-multiselect__dropdown-icon | The dropdownIcon section in WlConfig.pt.multiselect configuration. |
overlay | div.wl-overlay | The overlay section in WlConfig.pt.multiselect configuration. |
header | div.wl-multiselect__header | The header section in WlConfig.pt.multiselect configuration. |
selectAll | label.wl-multiselect__select-all | Label wrapping the select-all control. |
selectAllInput | input | Native checkbox selecting the enabled visible options. |
filterIcon | span | The filterIcon section in WlConfig.pt.multiselect configuration. |
filter.root | input.wl-input | Native input that receives focus and control attributes. |
listContainer | div.wl-select__list-container | The listContainer section in WlConfig.pt.multiselect configuration. |
loadingMessage | div.wl-select__empty | Loading state inside the options list. |
optionGroup | div.wl-select__group-label | Non-selectable group heading above its options. |
option | div.wl-select__option | The option section in WlConfig.pt.multiselect configuration. |
optionLabel | span | The optionLabel section in WlConfig.pt.multiselect configuration. |
emptyMessage | div.wl-select__empty | The emptyMessage section in WlConfig.pt.multiselect configuration. |
footer | div | Footer area below the main content. |
list | ul | The list section in WlConfig.pt.multiselect configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Set virtual to window a large option list. Options and group headings use the same fixed height, and keyboard navigation continues through the full filtered list.
- Name the native readonly combobox through id/label or aria-label. aria-expanded announces the open list; the listbox supports multiple selection.
- Arrows and Home/End move the active item; Enter toggles it; Escape closes the list. Selecting one item keeps the list open.
- In display=chip, each chip has a remove button named for the selected value. filter adds a “Filter” input to the panel.
- The model is TValue[]; its type is inferred from options and optionValue. maxSelectedLabels collapses labels only in display=comma. Associate errors through aria-describedby.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| ↑ / ↓ | Open the list and move the active option, skipping disabled options. |
| Home / End, PageUp / PageDown | Move to an edge or a page of available options while the list is active. |
| Enter | Choose the active option once. |
| Escape | Close the list and keep focus at its trigger or input. |
| Text | Type to search or use typeahead where the control is not editable. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.