Skip to content

Data display

ITree

A nested list that can be expanded and collapsed — a file browser, a category hierarchy, an org chart.

  • src
  • components
  • Button.vue
  • Input.vue
  • index.ts
  • README.md

Values, not objects

Both models are arrays of values: v-model holds what is selected, v-model:expanded holds what is open. A node's value identifies it, falling back to its label — so both models survive a round trip through a URL, a store or a request body.

ts
const items = [
  { label: 'src', value: 'src-dir', children: srcChildren },
  { label: 'README.md' }, //  value is "README.md"
]

Multiple selection

multiple lets several nodes be selected. Add propagate-select and choosing a folder chooses everything beneath it.

  • src
  • index.ts
  • README.md

Selected: index.ts

Counts

A node's count sits against the row's trailing edge, so the numbers line up in a column rather than stepping inward with each level.

  • src24
  • components18
  • composables6
  • index.ts
  • docs9
  • archive0

A count of 0 still renders.

Indentation

Depth is padding on the row rather than a nested container, so hover and selection backgrounds span the full width at every level.

indent sets how many pixels each level adds, on top of a small fixed inset.

vue
<ITree :items="files" :indent="24" />

Props

PropTypeDefaultDescription
itemsTreeItemOption[][]
modelValuestring[][]Selected values; v-model
expandedstring[][]Open values; v-model:expanded
multiplebooleanfalse
propagateSelectbooleanfalseSelecting a parent selects its descendants; needs multiple
size'sm' | 'md''md'
indentnumber16Pixels added per level
disabledbooleanfalse
ariaLabelstringNames the tree
unstyledbooleanSkip built-in classes
ui{ root?, item?, expander?, spacer?, icon?, label?, count? }Per-slot class overrides

TreeItemOption

FieldTypeDescription
labelstring
valuestringDefaults to the label
iconIconLike
disabledboolean
countnumberShown against the row's trailing edge; 0 still renders
childrenTreeItemOption[]Makes the node expandable

Events

EventPayload
update:modelValuestring[]
update:expandedstring[]

Slots

SlotPropsDescription
item{ item, level, expanded }Replaces a row's contents

Accessibility

Arrow keys move across the whole tree whatever the nesting: up and down walk the visible rows, right opens a branch, left closes it, and typing jumps to a matching label. A leaf reserves the same space a chevron takes, so the labels stay in one column.

Give the tree a name with ariaLabel.