DS0
Components

TreeView

Expandable/collapsible tree for hierarchical data with selection support.

Overview

TreeView displays hierarchical data in a nested, expandable tree structure. Supports single and multi-selection, checkboxes, async node loading, and keyboard navigation.

Usage

<TreeView
  data={[
    { id: '1', label: 'src', children: [
      { id: '1.1', label: 'components', children: [
        { id: '1.1.1', label: 'Button.tsx' },
        { id: '1.1.2', label: 'Card.tsx' },
      ]},
      { id: '1.2', label: 'utils', children: [
        { id: '1.2.1', label: 'cn.ts' },
      ]},
    ]},
  ]}
  onSelect={handleSelect}
/>

Accessibility

KeyAction
ArrowDown/UpNavigate between visible nodes
ArrowRightExpand or enter children
ArrowLeftCollapse or go to parent
Enter/SpaceSelect/activate node
Home/EndJump to first/last node
  • Uses role="tree" with role="treeitem" children
  • aria-expanded on parent nodes

API Reference

PropTypeDefaultDescription
dataTreeNode[][]Tree data
onSelect(node: TreeNode) => voidSelection handler
multiSelectbooleanfalseEnable multi-selection
checkablebooleanfalseShow checkboxes
defaultExpandedstring[][]Initially expanded node IDs
ComponentWhen to Use Instead
AccordionFlat expandable sections
JsonViewerJSON data tree

On this page