Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

Treeview

A compound component for building accessible hierarchical tree interfaces with expand/collapse and selection support.

Usage

The Treeview component provides a compound pattern for building accessible tree structures. It uses the createNested composable internally for hierarchical state management — tracking parent-child relationships, open/close state, and cascade selection.

Anatomy

vue
<script setup lang="ts">
  import { Treeview } from '@vuetify/v0'
</script>

<template>
  <Treeview.Root>
    <Treeview.List>
      <Treeview.Item>
        <Treeview.Activator>
          <Treeview.Cue />
          Label
        </Treeview.Activator>

        <Treeview.Content>
          <Treeview.Group>
            <Treeview.Item>
              <Treeview.Activator>Leaf</Treeview.Activator>
            </Treeview.Item>
          </Treeview.Group>
        </Treeview.Content>
      </Treeview.Item>
    </Treeview.List>
  </Treeview.Root>
</template>

For trees with selection, add Treeview.Checkbox and Treeview.Indicator:

vue
<script setup lang="ts">
  import { Treeview } from '@vuetify/v0'
</script>

<template>
  <Treeview.Root>
    <Treeview.List>
      <Treeview.Item>
        <Treeview.Activator>
          <Treeview.Cue />
        </Treeview.Activator>

        <Treeview.Checkbox>
          <Treeview.Indicator />
        </Treeview.Checkbox>

        Label

        <Treeview.Content>
          <Treeview.Group>
            <Treeview.Item>Leaf</Treeview.Item>
          </Treeview.Group>
        </Treeview.Content>
      </Treeview.Item>
    </Treeview.List>
  </Treeview.Root>
</template>

Configuration

Expansion Mode

Control how many nodes can be open at once with the open prop:

vue
<template>
  <!-- Default: multiple nodes can be open simultaneously -->
  <Treeview.Root open="multiple" />

  <!-- Accordion: only one node open at a time -->
  <Treeview.Root open="single" />
</template>

Use open-all to expand all nodes on mount:

vue
<template>
  <Treeview.Root open-all>
    <!-- All nodes start expanded -->
  </Treeview.Root>
</template>

Selection Mode

The selection prop controls how selection propagates through the hierarchy:

ValueBehavior
cascade (default)Selecting a parent selects all descendants; parents show tri-state when partially selected
independentEach node selected independently, no cascading
leafOnly leaf nodes can be selected; selecting a parent selects all its leaf descendants
vue
<template>
  <Treeview.Root v-model="selected" selection="leaf">
    <!-- Only leaf nodes appear in v-model -->
  </Treeview.Root>
</template>

Active Item

The active prop controls single vs. multi-highlight mode (independent of selection):

vue
<template>
  <!-- Default: only one item highlighted at a time -->
  <Treeview.Root active="single" />

  <!-- Multiple items can be highlighted simultaneously -->
  <Treeview.Root active="multiple" />
</template>

Reveal

Set reveal to automatically open all ancestor nodes when a descendant is opened. Useful for “navigate to item” patterns where a deep node is programmatically opened:

vue
<template>
  <Treeview.Root reveal>
    <!-- Opening a deep node opens its entire ancestor chain -->
  </Treeview.Root>
</template>

Examples

Recipes

Cascade Selection

Add v-model to Treeview.Root for cascade selection. Use Treeview.Checkbox and Treeview.Indicator for tri-state checkboxes. Use Treeview.SelectAll for a tree-wide toggle.

vue
<script setup lang="ts">
  import { Treeview } from '@vuetify/v0'
  import { ref } from 'vue'

  const selected = ref<string[]>([])
</script>

<template>
  <Treeview.Root v-model="selected">
    <Treeview.SelectAll>
      <Treeview.Indicator />
      Select All
    </Treeview.SelectAll>

    <Treeview.List>
      <Treeview.Item value="users">
        <Treeview.Checkbox>
          <Treeview.Indicator />
        </Treeview.Checkbox>
        Users

        <Treeview.Group>
          <Treeview.Item value="users:view">
            <Treeview.Checkbox>
              <Treeview.Indicator />
            </Treeview.Checkbox>
            View
          </Treeview.Item>

          <Treeview.Item value="users:create">
            <Treeview.Checkbox>
              <Treeview.Indicator />
            </Treeview.Checkbox>
            Create
          </Treeview.Item>
        </Treeview.Group>
      </Treeview.Item>
    </Treeview.List>
  </Treeview.Root>
</template>

Styling with Data Attributes

All sub-components expose data attributes for CSS-driven state styling:

ComponentAttributeValues
Itemdata-selectedPresent when selected
Itemdata-disabledPresent when disabled
Itemdata-openPresent when expanded
Itemdata-activePresent when active
Activatordata-disabledPresent when disabled
Activatordata-openPresent when expanded
Checkboxdata-selectedPresent when checked
Checkboxdata-disabledPresent when disabled
Checkboxdata-mixedPresent when indeterminate
Cuedata-stateopen or closed
Indicatordata-statechecked, unchecked, or indeterminate

The --v0-treeview-depth CSS variable is set on each Item, enabling indentation:

css
.tree-item {
  padding-left: calc(var(--v0-treeview-depth) * 1rem);
}

API Reference

The following API details are for all variations of the Treeview component.

Treeview.Root

Props

namespace

string | undefined

Namespace for dependency injection

disabled

boolean | undefined

Disables the entire tree

enroll

boolean | undefined

Auto-select non-disabled items on registration

mandatory

boolean | "force" | undefined

Prevents deselecting the last selected item

multiple

boolean | undefined

Allows selecting multiple items

open

NestedOpenMode | undefined

Controls how nodes expand: 'multiple' (default) or 'single' (accordion)

openAll

boolean | undefined

Auto-expand all nodes on registration

reveal

boolean | undefined

Opening a node also opens all its ancestors

selection

NestedSelectionMode | undefined

Controls how selection cascades: 'cascade' (default), 'independent', or 'leaf'

active

NestedActiveMode | undefined

Controls active/highlight mode: 'single' (default) or 'multiple'

Events

update:model-value

[value: T | T[]]

Slots

default

TreeviewRootSlotProps

Treeview.Activator

Props

namespace

string | undefined

Namespace for dependency injection

Treeview.Checkbox

Props

namespace

string | undefined

Namespace for dependency injection

Treeview.Content

Props

namespace

string | undefined

Namespace for dependency injection

Treeview.Cue

Props

namespace

string | undefined

Namespace for dependency injection

Treeview.Indicator

Props

namespace

string | undefined

Namespace for dependency injection

Treeview.Item

Props

id

ID | undefined

Unique identifier (auto-generated if not provided)

value

V | undefined

Value associated with this item

disabled

MaybeRefOrGetter<boolean> | undefined

Disables this item

namespace

string | undefined

Namespace for dependency injection

Slots

default

TreeviewItemSlotProps<V>

Treeview.List

Props

namespace

string | undefined

Namespace for dependency injection

multiselectable

boolean | undefined

Whether multiple items can be selected (sets aria-multiselectable)

label

string | undefined

Accessible label for the tree

Treeview.SelectAll

Props

label

string | undefined

Optional display label (passed through to slot and aria-label)

disabled

boolean | undefined

Disables this checkbox

namespace

string | undefined

Namespace for dependency injection

Was this page helpful?

Ctrl+/