An animated file tree component with smooth expand/collapse transitions.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- motion
- lucide-react
Code
"use client";
import MotionFileTree, { FileNode } from "@/registry/ruixenui/motion-file-tree";
const demoTree: FileNode[] = [
{
id: "1",
name: "src",
type: "folder",
children: [
{
id: "1-1",
name: "components",
type: "folder",
children: [{ id: "1-1-1", name: "Button.tsx", type: "file" }],
},
{ id: "1-2", name: "app.tsx", type: "file" },
{ id: "1-3", name: "styles.css", type: "file" },
],
},
{
id: "2",
name: "public",
type: "folder",
children: [{ id: "2-1", name: "favicon.ico", type: "file" }],
},
{ id: "3", name: "package.json", type: "file" },
];
export default function MotionFileTreeDemoPage() {
const handleSelect = (node: FileNode) => {
console.log("Selected node:", node);
};
return (
<div className="flex flex-col items-center py-16">
<MotionFileTree
data={demoTree}
defaultExpanded={{ "1": true, "1-1": true }}
onSelect={handleSelect}
/>
</div>
);
}
































