Data
Tree
Hierarchical data with branches that open and close, selection by click or checkbox, a filter, and children loaded on demand.
WAI-ARIA tested
Import
main.ts
import { Tree } from '@vitral/vue';Single selection, custom content
The default slot draws each node: here, its size beside the name.
- Pictures
- Music
- Notes.md4 KB
Checkboxes
Checking a branch checks everything under it; a branch with some of its children checked is mixed (aria-checked="mixed"). Ísland is disabled.
Filter
Matches stay, with the branches that lead to them opened. “evora” finds Évora.
- Americas
- Europe
Lazy children
Each region is a branch (`leaf: false`) with no children yet; opening it emits `node-expand`, and the app loads them.
- eu-west-1 (Dublin)
- sa-east-1 (São Paulo)
- ap-northeast-1 (Tōkyō)
API
Read from packages/vue/src/components/Tree/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| value | TreeNodeLike[] | — |
| selectionMode | 'single' | 'multiple' | 'checkbox' | — |
| filter | boolean | Adds a search box; matches stay visible with the branches that lead to them, expanded. |
| filterBy | string | string[] | Node fields to search, as a list or comma-separated. Defaults to `label`. |
| filterPlaceholder | string | — |
| loading | boolean | — |
| scrollHeight | string | The tree's maximum height before it scrolls. |
| emptyMessage | string | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| node-expand | node: TreeNodeLike | — |
| node-collapse | node: TreeNodeLike | — |
| node-select | node: TreeNodeLike | — |
| node-unselect | node: TreeNodeLike | — |
| filter | query: string | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| default | (props: TreeNodeSlotProps) | A node's content, in place of its label. |
| togglericon | (props: { node: TreeNodeLike; expanded: boolean }) | — |
| empty | — | — |