Skip to content
OTF Kit logoOTF Kit

Tree

Display

Recursive expandable tree view with selection, drag-reorder, and virtualization for 1000+ nodes.

View in Storybook
Tree
Loading Storybook preview…

Installation

bun add @otfdashkit/ui

Usage

Import Tree from @otfdashkit/ui.

Code
// Tree — Recursive expandable tree view with selection, drag-reorder, and virtualization for 1000+ nodes.
//
// Install:
//   bun add @otfdashkit/ui

import { Tree } from '@otfdashkit/ui'

export function Example() {
  return (
    <Tree>
      {/* your content */}
    </Tree>
  )
}

Props

Props declared in the Tree source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
datarequiredTreeNode[]
defaultExpandedIdsstring[]
estimatedRowHeightnumber32Used when virtualize=true. Default 32.
expandedIdsstring[]Controlled expanded ids.
onExpandedChange(ids: string[]) => void
onMove(sourceId: string, targetId: string, position: TreeMovePosition) => voidDefine to enable drag-reorder. Omit to disable drag entirely.
onSelect(node: TreeNode) => void
selectedIdstring
showLinesbooleantrueShow vertical guide lines from caret to children. Default true.
virtualizebooleanfalseUse @tanstack/react-virtual to virtualize visible rows. Default false.

Related