Tree
A hierarchical tree component for displaying nested data structures with expand/collapse, selection, and checkbox support.
Component Features
- 🌳 Hierarchical Display: Displays nested data with expand/collapse support.
- ✔️ Checkable Mode: Enables checkbox mode via
checkableprop with parent-child linkage. - 🔗 Selectable Mode: Supports single and multiple selection modes for nodes.
- 🚫 Disabled State: Supports
disabledfor individual nodes or entire tree. - ➡️ Connection Lines: Supports
showLineto display hierarchical connection lines. - 🔍 Node Filtering: Filters visible nodes via
filterTreeNode. - ⚡ Virtual Scrolling: Renders only visible nodes via
virtualScrollfor large datasets. - ✋ Drag & Drop: Supports drag-and-drop node reordering.
Basic
Pass nested data via the data prop. Each node requires a unique key and a label. Click the arrow icon to expand/collapse child nodes.
Selection
Use v-model:selectedKeys to control which nodes are selected. Click a node to select it. Set selectable to "multiple" for multi-select or "none" to disable selection.
Checkable
Set checkable to enable checkboxes. Use v-model:checkedKeys to control checked state. Parent-child linkage is built-in: checking a parent checks all children, and checking all children checks the parent.
Disabled & Show Line
Set disabled on individual nodes or the entire tree. Use showLine to display connecting lines between levels.
Filter
Use filterTreeNode to filter visible nodes. Pass a function that returns true for matching nodes. Matching nodes and their ancestors will be shown automatically.
Virtual Scroll
For large datasets, enable virtualScroll to render only visible rows. Set height to control the container height and itemHeight for each row height.
Drag & Drop
Set draggable to enable drag-and-drop reordering. Listen to drop event to handle the new position. Use allowDrop to restrict valid drop targets.
Theming
You can customize the appearance using Tailwind CSS classes or by overriding CSS variables.
CSS Variables
Tailwind Customization
Use the class prop to add custom styles: