Tree

A hierarchical list component where folders expand and only files are selectable.

  • app
  • components
  • Button.vue
  • Card.vue
  • Tree.vue
  • package.json
  • README.md

Expanded: [ "app", "components" ]

Selected Label: None

Installation

Terminal
npx shadcn-vue@latest add https://raya-ui.com/registry/tree.json

Props

PropTypeDefaultDescription
itemsArray[]The hierarchical data to render.
modelValueanyundefinedThe currently selected item. Use v-model.
labelKeystring'label'The property key to use for the item label.
childrenKeystring'children'The property key to use for nested children.
iconKeystring'icon'The property key to use for the item icon component/name.
selectionBehavior'toggle' | 'replace''toggle'Controls selection behavior. 'replace' deselects others on click (unless modifier key). 'toggle' adds/removes.
expandedstring[][]Keys of expanded items. Use v-model:expanded.

Emits

EventPayloadDescription
update:modelValueanyFired when selection changes.
update:expandedstring[]Fired when items are expanded or collapsed.

Slots

SlotPropsDescription
#item{ item, expanded, selected, indeterminate }Custom content for each tree item.