Tree
Tree component for files and categories, with the keyboard model of a native tree, controlled state and icons.
How to use it
Run npx @blossomui/react add tree, or copy src/components/UI/Tree/Tree.tsx into your React project and import it.
import { Tree } from './components/ui/Tree'Props
TreeNode
| Prop | Type | Description |
|---|---|---|
| id (required) | string | |
| label (required) | string | |
| icon | ReactNode | Element shown before the label, for example a file or folder icon. |
| children | TreeNode[] | Child nodes. A node with children can be opened and closed. |
| disabled | boolean |
TreeProps
| Prop | Type | Description |
|---|---|---|
| nodes (required) | TreeNode[] | |
| selected | string | null | Controlled selected node. Use together with `onSelect`. |
| defaultSelected | string | null | Node that starts selected when the tree is not controlled. |
| onSelect | (id: string, node: TreeNode) => void | |
| expanded | string[] | Controlled list of open nodes. Use together with `onExpandedChange`. |
| defaultExpanded | string[] | Open nodes when the tree is not controlled. |
| onExpandedChange | (ids: string[]) => void | |
| color | string | Accent color of the selected node: any CSS color. Without it the component uses `--blossom-accent`. |
| label | string | Accessible name of the tree. |
| className | string |