Selection
Layout
Tree
An indented, collapsible list for nested data, with single or multiple selection. Use it for file explorers and nested navigation.
Rows update from reactive state. In a custom #node slot, read reactive values (props, refs, computeds), not plain variables captured from the parent.
Install
import { Tree } from 'vael-ui'Playground
src
package.json
README.md
Project files
single
clone
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Tree } 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)
</script>
<template>
<Tree :items="items" v-model="value" />
</template>Motion New
Tree: its appearance, row by row.
<Tree
:motion="{ initial: { list: { opacity: 0, y: 4 } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | listnodechevronlabel | 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. |
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 Tree View pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| 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. |
| ArrowDown | Moves focus from the search box to the first row. |
| Space | Picks up the focused row when reorderable is set. |
| ArrowUpArrowDown | Moves the picked-up row up or down. |
| ArrowLeftArrowRight | Moves the picked-up row one level out or in. |
| SpaceEnter | Drops the picked-up row. |
| Escape | Cancels the move and puts the row back. |
role="tree"holdsrole="treeitem"rows witharia-level,aria-setsizeandaria-posinset; folders addaria-expanded.aria-label,aria-labelledbyandaria-describedbygo on the tree.- Rows carry
aria-selected, oraria-checkedincheckboxmode, with"mixed"for a partly checked folder.aria-multiselectableis set unless the mode issingle. - One row is in the tab order at a time, starting on the selected row; in
checkboxmode the checkboxes stay out of it. The exposedfocusNode(value)opens the folders above a row and focuses it. Typing the same letter again cycles through matches. - With
reorderable, Space picks a row up instead of selecting it; Enter still selects. Each move is announced through arole="status"live region. Right to left, ArrowLeft and ArrowRight swap.