Skip to content
Latestv1.0.63

TreeSelect ​

Select tree-structured data in a compact dropdown. YhTreeSelect supports single selection, multiple selection, checkbox linkage, filtering, lazy loading, and virtual scrolling for large datasets.

Basic Usage ​

Standard single-selection mode. By default, leaf nodes are the practical selection target, while parent nodes mainly expand or collapse the tree.

Basic Selection

Disabled State ​

You can disable the entire component or disable specific nodes through the data source.

Disabled State

Clearable ​

Set clearable to display a clear button when a value exists.

Clearable

Multiple Selection and Tag Folding ​

Use multiple to enable multi-selection. collapse-tags helps keep the trigger compact.

Multi Selection

Select Any Level ​

Enable check-strictly to allow selecting parent and child nodes independently.

Select Any Level

Checkbox Mode ​

Use show-checkbox when you want explicit checked states in tree selection.

Checkbox Mode

Filterable ​

With filterable enabled, users can type keywords directly into the trigger input.

Search Filter

Lazy Loading ​

Set lazy and provide load to fetch child nodes on demand.

Lazy Loading

Custom Node Content ​

Use the default slot to customize how nodes render inside the dropdown.

Custom Slot

Virtual Scrolling ​

Set virtual to true for very large trees.

Massive Data Search
Massive Data Checklist

Use in Nuxt ​

YhTreeSelect works in Nuxt after registering the YH-UI module. The initial tree structure and selected content render during SSR, while filtering, popup positioning, and lazy loading continue on the client after hydration.

Use in Nuxt

API ​

Props ​

NameDescriptionTypeDefault
model-value / v-modelBound valueYhTreeKey | YhTreeKey[]undefined
dataTree data sourceYhTreeOption[][]
propsField alias configurationYhTreePropsAlias{ label: 'label', value: 'value', children: 'children', disabled: 'disabled', isLeaf: 'isLeaf' }
placeholderPlaceholder textstringundefined
multipleWhether multiple selection is enabledbooleanfalse
clearableWhether the current value can be clearedbooleanfalse
disabledWhether the component is disabledbooleanfalse
sizeInput size'large' | 'default' | 'small''default'
filterableWhether node filtering is enabledbooleanfalse
filter-node-methodCustom filter function(value: string, data: YhTreeOption, node: YhTreeSelectNode) => booleanundefined
collapse-tagsWhether selected tags are collapsed in multiple modebooleanfalse
collapse-tags-tooltipWhether to show a tooltip summary when tags are collapsedbooleanfalse
max-collapse-tagsMaximum number of visible tags before collapsingnumber1
teleportedWhether the dropdown is teleported to bodybooleantrue
popper-classCustom class applied to the dropdown popperstring''
statusDeclared validation status prop. The current template and stylesheet do not consume it'' | 'success' | 'warning' | 'error'undefined
node-keyUnique node identifier field. When omitted, the runtime falls back to the field mapped by props.valuestringundefined
show-checkboxWhether checkboxes are shown before nodesbooleanfalse
check-strictlyWhether parent and child checked states are independentbooleanfalse
check-on-click-nodeWhether clicking a node toggles its checkboxbooleanfalse
expand-on-click-nodeWhether clicking a node expands or collapses itbooleantrue
default-expand-allWhether all nodes are expanded by defaultbooleanfalse
default-expanded-keysInitial expanded node keysYhTreeKey[][]
default-checked-keysDeclared initial checked node keys. The current tree-state initialization does not consume this propYhTreeKey[][]
accordionWhether only one sibling node can stay expanded at a timebooleanfalse
indentHorizontal indentation per tree levelnumber16
lazyWhether lazy loading is enabledbooleanfalse
loadLazy-load callback for child nodes(node: YhTreeOption, resolve: (data: YhTreeOption[]) => void) => voidundefined
virtualWhether virtual scrolling is enabledbooleanfalse
heightMaximum dropdown heightstring | number274
item-sizeEstimated item height used by virtual scrollingnumber34
empty-textCustom empty-state textstringundefined
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

NameDescriptionParameters
update:modelValueTriggered when the bound value changes(value: YhTreeKey | YhTreeKey[] | undefined) => void
changeTriggered when the selection changes(value: YhTreeKey | YhTreeKey[] | undefined) => void
visible-changeTriggered when dropdown visibility changes(visible: boolean) => void
clearTriggered when the clear button is clicked() => void
node-clickTriggered when a node row is clicked(data: YhTreeOption, node: YhTreeSelectNode, e: MouseEvent) => void
check-changeTriggered when checkbox state changes(data: YhTreeOption, checked: boolean, indeterminate: boolean) => void
checkTriggered when a checkbox is checked or unchecked(data: YhTreeOption, info: YhTreeCheckedInfo) => void

Slots ​

NameDescriptionParameters
defaultCustom content for tree nodes{ node: YhTreeSelectNode, data: YhTreeOption }

Expose ​

This component does not expose public instance methods or properties.

Type Exports ​

NameDescription
YhTreeSelectPropsProps type for YhTreeSelect
YhTreeSelectEmitsEmits type for YhTreeSelect
YhTreeSelectNodeInternal rendered tree node type exposed for callbacks
YhTreeOptionTree option data type
YhTreeKeyTree node key type
YhTreeCheckedInfoChecked-state payload type
YhTreePropsAliasField alias configuration type
YhTreeSelectInstanceComponent instance type

Theme Variables ​

YhTreeSelect supports themeOverrides. The stylesheet directly consumes the following component-scoped CSS variables:

VariableDescriptionDefault
--yh-tree-select-node-hover-bgNode background color on hovervar(--yh-fill-color-light, #f5f7fa)
--yh-tree-select-node-active-bgBackground color for the selected nodevar(--yh-color-primary-light-9, #ecf5ff)
--yh-tree-select-active-colorText color for selected nodesvar(--yh-color-primary, #409eff)

Released under the MIT License.