DocsGitHub
Getting Started
  • Overview
  • Design Tokens
Components
  • Accordion
  • Alert
  • Announcement
  • Avatar
  • Badge
  • BigCalendar
  • Breadcrumb
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Checkbox
  • Chip
  • CloseButton
  • Combobox
  • CommandPalette
  • ContextMenu
  • Currency
  • DatePicker
  • DescriptionList
  • Drawer
  • DropdownMenu
  • EmptyState
  • Field
  • FileUpload
  • FormGrid
  • Hotkey
  • Icon
  • Input
  • Metric
  • Modal
  • MultiSelect
  • NumberInput
  • Pagination
  • Popover
  • ProgressBar
  • Radio
  • Rating
  • SegmentedControl
  • Select
  • SelectionCard
  • Sidebar
  • Skeleton
  • Slider
  • Spinner
  • Stepper
  • Switch
  • Table
  • Tabs
  • Textarea
  • Timeline
  • TimePicker
  • Toast
  • Tooltip
  • TransferList
  • TreeView
  • Wizard
Charts
  • Overview
  • Area Chart
  • Bar Chart
  • Donut Chart
  • Line Chart
  • Pie Chart
  • Stacked Bar Chart

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

PropTypeDefaultDescription
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="دليل الحسابات" />