All skills
Skillintermediate
Component specification
A generic tree component that displays hierarchical data in a collapsible structure. It supports virtualization for performance with large datasets, provides flexible rendering through slots, and can work with any data type that implements the `TreeItem` interface.
Claude Code Knowledge Pack7/10/2026
Overview
Component specification
A generic tree component that displays hierarchical data in a collapsible structure. It supports virtualization for performance with large datasets, provides flexible rendering through slots, and can work with any data type that implements the TreeItem interface.
Generic Type Support
The Tree component is generic and can work with any data type that extends the base TreeItem interface:
interface TreeItem {
id: string;
children?: TreeItem[];
}
Public API Definition
Props
items: T[]- Tree data structure using generic type T (defaults to IMenuItem)estimateSize?: number- Estimated height of each tree item (in px) - used for virtualization |default: 32getKey?: (item: T) => string- Optional function to get unique key from each item |default: item.idmodelValue?: string[]- The controlled selected values of the Tree. Can be bind asv-modelexpanded?: string[]- The controlled expanded state of tree items. Can be bind asv-model:expandeddefaultExpanded?: string[]- The expanded state when initially renderedmultiple?: boolean- Whether multiple items can be selecteddisabled?: boolean- Whentrue, prevents user interaction with the Tree
Events
update:modelValue(value: string[])- Emitted when selection changesupdate:expanded([val: Record<string, any> | Record<string, any>[]])- Emitted when expanded items change
Slots
default:{ item: FlattenedItem; handleToggle: () => void; handleSelect: () => void; isExpanded: boolean, hasChildren: boolean }- Main content for each tree item.empty: - Slot for empty state.
Template usage example
Basic Usage
<script setup lang="ts">
const items = ref<IMenuItem[]>([...])
</script>
<template>
</template>
Custom slot and key
<script setup lang="ts">
interface CustomItem extends TreeItem {
uuid: string
name: string
children?: CustomItem[]
}
const customItems = ref<CustomItem[]>([
{
id: 'should-not-be-used',
uuid: 'abc-123',
name: 'Custom Item',
children: [
{
id: 'should-not-be-used',
uuid: 'def-456',
name: 'Child Item'
}
]
}
])
function getCustomKey(item: CustomItem) {
return item.uuid
}
</script>
<template>
<template #default="{ item, handleToggle, isExpanded, hasChildren }">
<div>
<span>{{ item.value.name }} ({{ item.value.uuid }})</span>
</div>
</template>
<template #empty>
<p>No custom items to display</p>
</template>
</template>