Selection
Layout
Combobox
A searchable dropdown that also accepts free text. Use it for autocomplete, or for tags people create as they type.
Validating a form? vael-form wires this up with a schemaInstall
import { Combobox } from 'vael-ui'Playground
Fruits
undefined
Placement, behaviour and animation
undefined
bottom
start
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Combobox } 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>
<Combobox
placeholder="Choose an option"
aria-label="Fruits"
:items="items"
v-model="value"
v-model:open="open"
/>
</template>Motion New
Combobox's panel: values or hooks for its parts, like Popover's. chips moves the chips.
<Combobox
: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 |
|---|---|
| A letter | Types into the input and opens the list, filtered to the matches. |
| ArrowDownArrowUp | Opens the list, then moves the highlight, wrapping at the ends. |
| HomeEnd | Moves the highlight to the first or last option while the list is open. |
| Enter | Selects or toggles the highlighted option; with allowCustom and none highlighted, adds the typed text. |
| Escape | Closes the list and puts back the selected label if you typed. |
| Backspace | Removes the last chip when the input is empty (multiple). |
| DeleteBackspace | Removes the focused chip. |
| Tab | Closes the list and moves focus on; with tabBehavior, it commits the highlighted option or the typed text first. |
- The input has
role="combobox"witharia-autocomplete="list",aria-expandedandaria-controls. Options haverole="option"andaria-selected, plusaria-setsizeandaria-posinsetin a virtualized list. - Focus stays in the input, and
aria-activedescendantpoints at the highlighted option. The list opens on focus unlessopenOnFocusisfalse. - Chips sit outside the input and are Tab stops. When a focused chip is removed, focus moves to the next chip, the previous one, or the input. Clear returns focus to the input.
- Inside a
Field, the label names the input. Without one, passaria-label.