Selection
Layout
TreeSelect
A dropdown with a Tree in its panel, for picking one or more nodes from a hierarchy. Use it when a form field takes a value from nested data.
Validating a form? vael-form wires this up with a schemaInstall
import { TreeSelect } from 'vael-ui'Playground
Choose an option
Project files
single
undefined
Placement, behaviour and animation
bottom
start
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { TreeSelect } from 'vael-ui'
const items = [
{ label: 'src', value: 'src', children: [
{ label: 'App.vue', value: 'src/App.vue' },
{ label: 'main.ts', value: 'src/main.ts' },
] },
{ label: 'README.md', value: 'README.md' },
]
const value = ref<string | number | (string | number)[] | null>(null)
const open = ref(false)
</script>
<template>
<TreeSelect
placeholder="Choose an option"
aria-label="Project files"
:items="items"
v-model="value"
v-model:open="open"
/>
</template>Motion New
TreeSelect's panel: values or hooks for its parts, like Popover's.
<TreeSelect
: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. |
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
| Key | Action |
|---|---|
| ArrowDownArrowUpEnterSpace | Opens the tree from the trigger. |
| ArrowDownArrowUp | Moves focus to the next or previous visible row. |
| HomeEnd | Moves focus to the first or last visible row. |
| ArrowRight | Expands a closed folder, or moves focus to the first child of an open one. |
| ArrowLeft | Collapses an open folder, or moves focus to the parent row. |
| EnterSpace | Selects or checks the focused row. |
| A letter | Moves focus to the next row whose label starts with the typed letters. |
| Escape | Closes the panel and returns focus to the trigger. |
- The trigger has
role="combobox"witharia-haspopup="tree",aria-expandedandaria-controlspointing at the tree. The tree has the same roles as Tree and takes the trigger’s label. - On open, focus moves to the selected row, opening the folders above it, or else to the first row. With
filterable, it moves to the search box. A single selection closes the panel;multipleandcheckboxkeep it open. - 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. Right to left, ArrowLeft and ArrowRight swap.