Tree

A collapsible, keyboard-navigable tree view for hierarchical data: file trees, org charts, and nested navigation.

Installation

npx dafink-ui add tree

Demo

src
components
Button.tsx
Input.tsx
package.json
tsconfig.json

Composition

<Tree>
<TreeItem>
<TreeItem />/* recursive */
</TreeItem>
</Tree>

Props

NameTypeDefaultDescription
labelReactNode-The text or content displayed for the node. (TreeItem)
childrenReactNode-Nested TreeItem elements. Presence makes this a branch node. (TreeItem)
defaultOpenbooleanfalseWhether a branch starts expanded on initial render. (TreeItem)
collapsiblebooleantrueWhen false, the branch is always expanded with no toggle affordance: no chevron, not focusable, no hover/focus state. For read-only structural diagrams. (TreeItem)
iconReactNode-Custom icon for this item, overriding the tree-level terminalIcon/nonTerminalIcon and (for collapsible branches) the default chevron. (TreeItem)
disabledbooleanfalseDisables interaction. Item is visible but not clickable or focusable. (TreeItem)
classNamestring""Additional classes on the item row or tree root element.
terminalIconReactNode-Default icon shown for leaf items (no children) that don’t set their own icon. No icon renders if unset. (Tree)
nonTerminalIconReactNode-Default icon shown for non-collapsible branch items that don’t set their own icon. Collapsible branches keep the chevron instead. No icon renders if unset. (Tree)
selectablebooleanfalseAllows text selection/copy inside the tree. Off by default since a normal interactive tree treats click as select/toggle. Turn on for read-only, fully non-collapsible trees. (Tree)