Tree
Kibo Tree uses a provider for expansion, selection and optional multi-selection.
Practical React example
Browse nested application resources with stable IDs and deliberate selection behavior.
Before you copy and paste
Use the composed primitives together under their required provider, where one is present. Copy components/kibo-ui/tree/index.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: lucide-react, motion.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Browse nested application resources with stable IDs and deliberate selection behavior
// Usage adapted from Kibo UI's pinned MIT source.
// Copyright (c) 2023 — Present shadcnblocks. See ./LICENSES.md.
"use client";
import {
TreeExpander,
TreeIcon,
TreeLabel,
TreeNode,
TreeNodeContent,
TreeNodeTrigger,
TreeProvider,
TreeView,
} from "@/components/kibo-ui/tree";
import { FileCode, FileJson, FileText } from "lucide-react";
export default function TreeExample() {
return (
<TreeProvider
defaultExpandedIds={["src", "components", "ui"]}
onSelectionChange={(ids) => console.log("Selected:", ids)}
>
<TreeView>
<TreeNode nodeId="src">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>src</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode level={1} nodeId="components">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>components</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode level={2} nodeId="ui">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>ui</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode level={3} nodeId="button.tsx">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileCode className="h-4 w-4" />} />
<TreeLabel>button.tsx</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode level={3} nodeId="card.tsx">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileCode className="h-4 w-4" />} />
<TreeLabel>card.tsx</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode isLast level={3} nodeId="dialog.tsx">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileCode className="h-4 w-4" />} />
<TreeLabel>dialog.tsx</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
</TreeNodeContent>
</TreeNode>
<TreeNode isLast level={2} nodeId="layout">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>layout</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode level={3} nodeId="header.tsx">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileCode className="h-4 w-4" />} />
<TreeLabel>header.tsx</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode isLast level={3} nodeId="footer.tsx">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileCode className="h-4 w-4" />} />
<TreeLabel>footer.tsx</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
</TreeNodeContent>
</TreeNode>
</TreeNodeContent>
</TreeNode>
</TreeNodeContent>
</TreeNode>
<TreeNode nodeId="public">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>public</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode isLast level={1} nodeId="images">
<TreeNodeTrigger>
<TreeExpander hasChildren />
<TreeIcon hasChildren />
<TreeLabel>images</TreeLabel>
</TreeNodeTrigger>
<TreeNodeContent hasChildren>
<TreeNode level={2} nodeId="logo.svg">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileText className="h-4 w-4" />} />
<TreeLabel>logo.svg</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode isLast level={2} nodeId="hero.png">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileText className="h-4 w-4" />} />
<TreeLabel>hero.png</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
</TreeNodeContent>
</TreeNode>
</TreeNodeContent>
</TreeNode>
<TreeNode nodeId="package.json">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileJson className="h-4 w-4" />} />
<TreeLabel>package.json</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode nodeId="tsconfig.json">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileJson className="h-4 w-4" />} />
<TreeLabel>tsconfig.json</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
<TreeNode isLast nodeId="README.md">
<TreeNodeTrigger>
<TreeExpander />
<TreeIcon icon={<FileText className="h-4 w-4" />} />
<TreeLabel>README.md</TreeLabel>
</TreeNodeTrigger>
</TreeNode>
</TreeView>
</TreeProvider>
);
}
Usage example adapted from Kibo UI's pinned MIT source. Retain the source licence notices when copying.
Keep resource IDs stable and use selectedIds and onSelectionChange when the surrounding application owns the selection. Decide how deleted descendants affect selected parents.
Customization
- TreeProviderProps.children
- Required; ReactNode.
- TreeProviderProps.defaultExpandedIds
- Optional; string[].
- TreeProviderProps.showLines
- Optional; boolean.
- TreeProviderProps.showIcons
- Optional; boolean.
- TreeProviderProps.selectable
- Optional; boolean.
- TreeProviderProps.multiSelect
- Optional; boolean.
- TreeProviderProps.selectedIds
- Optional; string[].
- TreeProviderProps.onSelectionChange
- Optional; (selectedIds: string[]) => void.
- TreeProviderProps.indent
- Optional; number.
- TreeProviderProps.animateExpand
- Optional; boolean.
- TreeProviderProps.className
- Optional; string.
- TreeNodeProps.nodeId
- Optional; string.
- TreeNodeProps.level
- Optional; number.
- TreeNodeProps.isLast
- Optional; boolean.
Integration notes
- The tree does not enumerate files or authorize access to their contents.
- Test keyboard navigation, long labels and a non-drag workflow if you add resource movement.
Component source: Kibo UI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.