WlMultiSelect

Multiple selection. Selected values appear as chips or comma-separated text; a filter can be enabled in the list.
Components / Inputs v0.2.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

size

Field size.

density

Density.

display

comma — comma-separated labels; chip — individual chips.

placeholder

Placeholder.

maxSelectedLabels
Not set

Number of labels shown before a count replaces them. Only for display="comma".

Error state.

Disables the field.

Filter field inside the list.

List animation; defaults to WlConfig.motion (true).

Show the action for toggling all eligible filtered options.

Indicate pending work supplied by the application.

Props options, optionLabel, optionValue, pt, optionDisabled, optionKey, optionGroupLabel, optionGroupChildren, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

DesignDevelopment
Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<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

DesignDevelopment
Type a name in the filter; selected chips can be removed individually.
2 selected

Enter toggles the selected item; the list stays open for the next selection. Escape closes it.

Sizes and states

Design, Development
Design, Development
Design, Development
Design, Development
Design, Development
Design

Selected: 2. Values: design, code.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlField, WlMultiSelect } from "legato-ui";
import { 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" }];
</script>

<template>
  <div class="wl-stack" data-space="xl" data-input-example="WlMultiSelect">
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "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-title">{{ "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>
  </div>
</template>