R

Tree

2 parts

Anatomy

Import the parts and compose them. Each part forwards attributes to its underlying element.

vue
import {
  TreeRoot,
  TreeItem,
} from '@robonen/primitives/tree';

<TreeRoot>
  <TreeItem />
</TreeRoot>

API Reference

TreeRoot

Root
PropTypeDescription
itemsreadonly U[]Flat or nested item list — children are resolved via `getChildren`.
getKey(item: U) => stringExtract a stable unique string key from an item.
getChildren?(item: U) => readonly U[] | undefined | nullReturn the children of an item, or `undefined` if it is a leaf.
modelValue?string | string[]Controlled selected key(s). Use `v-model`.
defaultValue?string | string[]Uncontrolled initial selected key(s).
expanded?string[]Controlled expanded keys. Use `v-model:expanded`.
defaultExpanded?string[]Uncontrolled initial expanded keys.
multiple?booleanAllow selecting multiple items.
disabled?booleanDisable the entire tree.
dir?'ltr' | 'rtl'Writing direction.
propagateSelect?booleanWhen `true`, selecting a parent also selects all of its descendants (requires `multiple`).

TreeItem

Item
PropTypeDescription
itemFlatItem<U>Flattened item produced by `TreeRoot` (from its default slot).
disabled?booleanDisable this specific item.