Selection
Layout
Select
A dropdown for picking one or more values from a list, with filtering and virtualization. Use it when a list is too long for radios or a SelectButton.
Validating a form? vael-form wires this up with a schemaInstall
import { Select } from 'vael-ui'Playground
Choose an option
Fruits
undefined
chip
Placement, behaviour and animation
bottom
start
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Select } from 'vael-ui'
const items = [
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
{ label: 'Cherry', value: 'cherry' },
]
const value = ref<string | number | (string | number)[] | null>(null)
const open = ref(false)
</script>
<template>
<Select
placeholder="Choose an option"
aria-label="Fruits"
:items="items"
v-model="value"
v-model:open="open"
/>
</template>Motion New
Select's panel: values or hooks for its parts, like Popover's. chips moves the chips; valueSwap: false shows a picked value without its crossfade.
<Select
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | positionerpanel | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
chips | ChipsMotion | A select's chips (multiple): values or hooks for chip, and the list's stagger and leaving. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Combobox pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowDownArrowUpEnterSpace | Opens the list when it’s closed. |
| ArrowDownArrowUp | Moves the highlight to the next or previous option, wrapping at the ends. |
| HomeEnd | Moves the highlight to the first or last option. |
| EnterSpace | Selects the highlighted option, or toggles it with multiple. |
| A letter | Moves the highlight to the next option whose label starts with the typed letters. |
| BackspaceDelete | Removes the last chip, with multiple. |
| Escape | Closes the list and puts focus on the trigger. |
| Tab | Closes the list and moves focus on. |
- The trigger has
role="combobox"witharia-haspopup="listbox",aria-expandedandaria-controls. Options haverole="option"andaria-selected;multipleaddsaria-multiselectable, and a virtualized list addsaria-setsizeandaria-posinset. Groups render asrole="group", named by their label. - Focus stays on the trigger, and
aria-activedescendantpoints at the highlighted option, starting on the selected one. Withfilter, focus moves to the search box, which becomes the combobox; Space types a space there. - A single select closes when you pick;
multiplestays open. Chip remove buttons are pointer only. The clear button is a Tab stop, and clearing puts focus back on the trigger. - Inside a
Field, the label names the trigger. Without one, passaria-labeloraria-labelledby.