Tree
A hierarchical list component with nested items, expansion, and selection.
- app
- components
- Button.vue
- Card.vue
- Tree.vue
- pages
- assets
- package.json
- README.md
Expanded: [ "app", "components" ]
Selected: null
Installation
Terminal
npx shadcn-vue@latest add https://raya-ui.com/registry/tree.jsonProps
| Prop | Type | Default | Description |
|---|---|---|---|
| items | Array | [] | The hierarchical data to render. |
| modelValue | any | undefined | The currently selected item(s). Use v-model. |
| expanded | string[] | [] | Keys of expanded items. Use v-model:expanded. |
| labelKey | string | 'label' | Key to access the label in your data objects. |
| childrenKey | string | 'children' | Key to access nested children in your data objects. |
| multiple | boolean | false | Allow selecting multiple items. |
| propagateSelect | boolean | true | If true, selection state propagates down to children (if multiple). |
Emits
| Event | Payload | Description |
|---|---|---|
| update:modelValue | any | Fired when selection changes. |
| update:expanded | string[] | Fired when items are expanded or collapsed. |
| select | node | Fired when a node is selected. |
Slots
| Slot | Props | Description |
|---|---|---|
| #item | { item, expanded, selected } | Custom content for each tree item. |