TreeView
Navigates recursive account, bill-of-material, and organization hierarchies with the ARIA tree keyboard pattern.
Default
Arrow keys move through visible nodes. Inline-end expands and inline-start collapses or returns to the parent.
- Assets
- Current assets
- Cash and cash equivalents
- Accounts receivable
- Property, plant and equipment
- Liabilities
- Archived accounts
tsx
<TreeView nodes={nodes} defaultExpanded={["assets", "current"]} aria-label="Chart of accounts" />Installation
tsx
import { TreeView } from "madagent";Controlled
Expansion and selection can be owned independently by the application.
Selected: none
- Assets
- Current assets
- Property, plant and equipment
- Liabilities
- Archived accounts
tsx
<TreeView expanded={expanded} onExpandedChange={setExpanded} selected={selected} onSelect={setSelected} nodes={nodes} />Navigation Only
Use selectionMode none when the tree only reveals hierarchy.
- Assets
- Liabilities
- Archived accounts
tsx
<TreeView nodes={nodes} selectionMode="none" />Custom Node Renderer
- Assets
- Current assets
- Property, plant and equipment
- Liabilities
- Archived accounts
tsx
<TreeView nodes={nodes} renderNode={(node) => <strong>{node.label}</strong>} />API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
nodes | TreeNode[] | - | Recursive tree data with ids, labels, icons, children, and disabled state |
expanded | string[] | - | Controlled expanded node ids |
defaultExpanded | string[] | [] | Initial expanded ids |
onExpandedChange | (ids: string[]) => void | - | Called when branches expand or collapse |
selected | stringnull | - | Controlled selected node |
onSelect | (id: string | null) => void | - | Called when selection changes |
selectionMode | "single""none" | "single" | Enables selection or navigation-only behavior |
renderNode | (node: TreeNode) => ReactNode | - | Custom label renderer |
RTL Support
Components automatically adapt to right-to-left languages using CSS logical properties.
Preview
- الأصول
- النقد وما في حكمه
- الذمم المدينة
- الالتزامات
Usage
tsx
<TreeView nodes={arabicNodes} defaultExpanded={["assets-ar"]} aria-label="دليل الحسابات" />