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
| Prop | Type | Default | |
|---|---|---|---|
nodes | readonly TreeViewNode[] | Root nodes; nodes with children render as expandable branches. Or compose them as children: TreeView.Item elements, nested for branches. | |
children | ReactNode | The compound form instead of nodes: TreeView.Item elements. | |
expanded | string[] | Ids of expanded nodes. | |
defaultExpanded | string[] | [] | Initial expanded when uncontrolled. |
onExpandedChange | (expanded: string[]) => void | Called with the new expanded when it changes. | |
selected | string | null | Id of the selected node. | |
defaultSelected | string | null | null | Initial selected when uncontrolled. |
onSelectedChange | (id: string | null) => void | Called 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
- List Block — List with images or icons, descriptions and values
- Description List — Key–value list: stacked, inline or a grid with icons
- Accordion — Collapsible sections
- Sortable — Drag-and-drop sorting
- JSON Viewer — JSON viewer
- Timeline — Event timeline
- Data Table — Tables with search and sorting
- Data Grid — Grid for 100,000 rows: grouping, filters, inline editing
- Virtual List — Virtual list for 100,000 rows
- Bulk Action Bar — Actions for selected rows, with keyboard shortcuts
- Card — All-purpose cards
- Item Card — Row card: icon, title, description and a control on the right
Previous: Description List · Next: Accordion · All Data and metrics