Data Display
Tree
Recursive tree view with expand/collapse, checkboxes, icons (Folder/File), and connecting lines.
With icons
src
components
button.tsx
input.tsx
app.tsx
index.ts
public
package.json
Checkable + lines
src
components
app.tsx
index.ts
public
package.json
Installation
npx benflux-ui add treeUsage
import { Tree, type TreeDataNode } from "@benflux-ui/react"
const data: TreeDataNode[] = [
{
key: "src",
title: "src",
children: [
{ key: "app", title: "app.tsx" },
{ key: "index", title: "index.ts" },
],
},
]
<Tree
treeData={data}
showIcon
showLine
checkable
defaultExpandedKeys={["src"]}
onSelect={(keys) => console.log(keys)}
onCheck={(keys) => console.log(keys)}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| treeData* | TreeDataNode[] | — | Hierarchical data for the tree |
| showIcon | boolean | false | Show Folder/File icons automatically |
| showLine | boolean | false | Draw connecting lines between nodes |
| checkable | boolean | false | Add checkboxes to each node |
| defaultExpandedKeys | string[] | [] | Keys expanded on initial render |
| checkedKeys | string[] | — | Controlled checked key set |
| onSelect | (keys: string[]) => void | — | Called when a node is selected |
| onCheck | (keys: string[]) => void | — | Called when a checkbox is toggled |