Items
requireditems is the tree data. Each item can nest children, carry an icon, start expanded with defaultExpanded, or opt out with disabled.
Model value
modelValue sets which item is selected, two-way bound. A single value unless multiple is set.
Selected: none
modelValue is a single value normally, but becomes an array automatically when multiple is set — same pattern as Select.
Default value
defaultValue is the initial selection when uncontrolled.
Multiple
multiple lets more than one item be selected, and turns modelValue into an array.
Selected: none
Expanded
expanded sets which nodes are open, by key — bind it with v-model:expanded when something outside the tree needs to expand or collapse it.
Expansion state (expanded) and selection state (modelValue) are controlled independently; expanding a node doesn't select it.
Default expanded
Which nodes start open when uncontrolled. Falls back to each item's own defaultExpanded flag when omitted.
Disabled
disabled freezes the whole tree — nothing selects, nothing expands.
Color
color is the selected item's color.
API Reference
Generated from the component's source — props, slots and emits as the component actually declares them.
Props
string | string[]string[]string[]"neutral" | "primary" | "secondary" | "success" | "error" | "warning" | "info" | "pending"'neutral'Emits
update:modelValue[value: string | string[] | undefined]update:expanded[value: string[]]select[item: TreeItem]toggle[item: TreeItem, expanded: boolean]Types
type TreeColor = "neutral" | "primary" | "secondary" | "success" | "error" | "warning" | "info" | "pending";interface TreeItem {
label: string;
icon?: string;
children?: TreeItem[];
value?: string;
disabled?: boolean;
defaultExpanded?: boolean;
}interface TreeContext {
selectedKeys: ComputedRef<string[]>;
expandedKeys: ComputedRef<string[]>;
toggleSelect: (key: string, item: TreeItem) => void;
toggleExpand: (key: string, item: TreeItem) => void;
multiple: ComputedRef<boolean>;
disabled: ComputedRef<boolean>;
color: ComputedRef<TreeColor>;
}