WlSelect
Selection
Full example
<script setup lang="ts">
import { WlSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref<string | null>("team");
const options = computed(() => [{
label: "Scope",
items: [
{ label: "Team", value: "team", disabled: false },
{ label: "Personal", value: "personal", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
filter
clearable
aria-label="Scope"
/>
</div>
</template>Size and density
Full example
<script setup lang="ts">
import { WlSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref<string | null>("team");
const options = computed(() => [{
label: "Scope",
items: [
{ label: "Team", value: "team", disabled: false },
{ label: "Personal", value: "personal", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
filter
clearable
aria-label="Scope"
/>
</div>
</template>Example data
Full example
<script setup lang="ts">
import { WlSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref<string | null>("team");
const options = computed(() => [{
label: "Scope",
items: [
{ label: "Team", value: "team", disabled: false },
{ label: "Personal", value: "personal", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
filter
clearable
aria-label="Scope"
/>
</div>
</template>States
Full example
<script setup lang="ts">
import { WlSelect } from "legato-ui";
import { computed, ref } from "vue";
const value = ref<string | null>("team");
const options = computed(() => [{
label: "Scope",
items: [
{ label: "Team", value: "team", disabled: false },
{ label: "Personal", value: "personal", disabled: false },
{ label: "Research", value: "research", disabled: true }
]
}]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlSelect
v-model="value"
:options="options"
option-group-label="label"
option-group-children="items"
option-label="label"
option-value="value"
option-disabled="disabled"
filter
clearable
aria-label="Scope"
/>
</div>
</template>Object options and states
Separate label/id, three sizes and compact, accessible names, error, disabled and external clearing.
Sizes, density and object options
The model stores id; the list shows label. Arrow keys move the highlight, Enter selects and Escape closes the list.
Error, disabled and clearing
Model value: team.
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, WlSelect } from "legato-ui";
import { computed, ref } from "vue";
const area = ref<string | null>("team");
const options = [{ id: "personal", label: "Personal space" }, { id: "team", label: "Team" }, { id: "public", label: "Public materials" }];
const largeOptions = computed(() => Array.from({ length: 5000 }, (_, index) =>
["Record", index + 1].join(" ")
));
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlSelect">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Sizes, density and object options" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
v-for="size in ['sm', 'md', 'lg'] as const"
:id="`docs-select-${size}`"
:key="size"
v-slot="{ id }"
:label="`${'Space, '}${size}`"
><WlSelect
:id="id"
v-model="area"
:size="size"
:aria-label="`${'Space, '}${size}`"
:options="options"
option-label="label"
option-value="id"
placeholder="Choose a space"
/></WlField>
<WlField id="docs-select-compact" v-slot="{ id }" label="Compact list"><WlSelect
:id="id"
v-model="area"
density="compact"
aria-label="Compact list"
:options="options"
option-label="label"
option-value="id"
placeholder="Choose a space"
/></WlField>
</div>
<p class="wl-text-small wl-text-muted">{{ "The model stores id; the list shows label. Arrow keys move the highlight, Enter selects and Escape closes the list." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Error, disabled and clearing" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
id="docs-select-required"
v-slot="{ id, ariaDescribedby, invalid }"
label="Required space"
:error="area == null ? 'Choose a space.' : undefined"
><WlSelect
:id="id"
v-model="area"
:options="options"
option-label="label"
option-value="id"
:invalid="invalid"
aria-label="Required space"
:aria-describedby="ariaDescribedby"
placeholder="Choose a space"
/></WlField>
<WlField id="docs-select-disabled" v-slot="{ id }" label="Unavailable list"><WlSelect
:id="id"
model-value="team"
:options="options"
option-label="label"
option-value="id"
aria-label="Unavailable list"
disabled
/></WlField>
</div>
<WlButton size="sm" @click="area = null">{{ "Clear selection" }}</WlButton>
<p class="wl-text-small" role="status">{{ "Model value:" }} {{ area ?? 'null' }}.</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "5,000 options" }}</h3>
<WlSelect
aria-label="5,000 options"
:options="largeOptions"
virtual
filter
clearable
/>
<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: WlSelectModel<Selected value from optionValue; without a resolver, TOption. No default; the model can be omitted.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
virtual | WlVirtualOptions | false | — |
options | readonly TOption[] | [] | Readonly TOption list; the model 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 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. |
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. |
clearable | boolean | false | Show a named clear button; clears a single model to null. |
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. |
filter | boolean | false | Enable local filtering of available options. |
loading | boolean | false | Indicate pending work supplied by the application. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | WlSelectModel< | 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: { option: Option | | Selected value scope: { option, placeholder }. |
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. |
Pass-through: pt
Sections WlSelect 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-select | The root section in WlConfig.pt.select configuration. |
label | span.wl-select__label | The label section in WlConfig.pt.select configuration. |
clearButton | button.wl-select__clear | Button that clears the current value. |
dropdown | span.wl-select__dropdown | The dropdown section in WlConfig.pt.select configuration. |
dropdownIcon | span.wl-select__dropdown-icon | The dropdownIcon section in WlConfig.pt.select configuration. |
overlay | div.wl-overlay | The overlay section in WlConfig.pt.select configuration. |
header | div.wl-select__header | Component heading area. |
filterInput | input.wl-input | Native input that filters the visible options. |
listContainer | div.wl-select__list-container | The listContainer section in WlConfig.pt.select 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.select configuration. |
optionLabel | span.wl-select__option-label | The optionLabel section in WlConfig.pt.select configuration. |
emptyMessage | div.wl-select__empty | The emptyMessage section in WlConfig.pt.select configuration. |
footer | div | Footer area below the main content. |
list | ul | The list section in WlConfig.pt.select 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.
- The root combobox is a div, so a regular label for does not name it. Set aria-label or aria-labelledby.
- Arrows, Enter or Space open the list; arrows and Home/End move the active item; Enter selects; Escape closes.
- optionLabel defines the label; optionValue defines the model value. Values are compared with Object.is; keep them stable.
- Add associated error text to invalid. The application clears the nullable model; disabled removes the combobox from the Tab order.
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.