ValyroUI Русская версия

Tree View

Tree structures. Free, MIT · Data and metrics › Lists and trees

Installation

npx valyro-cli@latest add tree-view
npx shadcn@latest add https://valyro.xyz/r/tree-view.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { TreeView } from 'valyro-ui';

Props

PropTypeDefault
nodesreadonly TreeViewNode[]Root nodes; nodes with children render as expandable branches. Or compose them as children: TreeView.Item elements, nested for branches.
childrenReactNodeThe compound form instead of nodes: TreeView.Item elements.
expandedstring[]Ids of expanded nodes.
defaultExpandedstring[][]Initial expanded when uncontrolled.
onExpandedChange(expanded: string[]) => voidCalled with the new expanded when it changes.
selectedstring | nullId of the selected node.
defaultSelectedstring | nullnullInitial selected when uncontrolled.
onSelectedChange(id: string | null) => voidCalled with the new selected when it changes.
animation'default' | 'spring''default'A branch unfolds, pushing the rows below down, and folds away again when closed (it stays mounted until it has). spring: it opens on a spring. default: on the theme's curve and duration.

Compound parts

TreeView.Item (TreeViewItem)

Related components

Previous: Description List · Next: Accordion · All Data and metrics