Rendyn

Component library

189 components

Interaction

File Tree

File Tree supplies file and folder primitives with selected and expanded values.

Interactive exampleReact Tailwind CSS

Practical React example

Browse a project’s files using stable file IDs and explicit folder expansion.

Before you copy and paste

Keep the example in the React rendering environment required by the imported component. Copy components/motion/file-tree.tsx and its returned support files from the Code tab; preserve the project-relative paths.

Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.

Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.

Browse a project’s files using stable file IDs and explicit folder expansion

// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";

import {
  Braces,
  FileCode2,
  FileJson2,
  FileText,
  Palette,
} from "lucide-react";
import {
  FileTree,
  FileTreeFile,
  FileTreeFolder,
} from "@/components/motion/file-tree";

export function FileTreePreview() {
  return (
    <div className="flex min-h-[420px] w-full items-start justify-center px-4 pt-10">
      <div className="w-full max-w-xs p-2">
        <FileTree
          defaultValue="file-tree"
          defaultExpandedIds={["app", "components"]}
          ariaLabel="Project files"
        >
          <FileTreeFolder value="app" name="app">
            <FileTreeFolder value="components" name="components">
              <FileTreeFile
                value="file-tree"
                name="file-tree.tsx"
                icon={<Braces className="size-4 text-sky-500" />}
              />
              <FileTreeFile
                value="button"
                name="button.tsx"
                icon={<Braces className="size-4 text-sky-500" />}
              />
            </FileTreeFolder>
            <FileTreeFile
              value="page"
              name="page.tsx"
              icon={<FileCode2 className="size-4 text-sky-500" />}
            />
            <FileTreeFile
              value="styles"
              name="globals.css"
              icon={<Palette className="size-4 text-violet-500" />}
            />
          </FileTreeFolder>
          <FileTreeFolder value="public" name="public">
            <FileTreeFile value="logo" name="logo.svg" />
            <FileTreeFile value="grid" name="grid.svg" />
          </FileTreeFolder>
          <FileTreeFile
            value="package"
            name="package.json"
            icon={<FileJson2 className="size-4 text-amber-500" />}
          />
          <FileTreeFile
            value="readme"
            name="README.md"
            icon={<FileText className="size-4 text-muted-foreground" />}
          />
        </FileTree>
      </div>
    </div>
  );
}

Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.

Use IDs that remain stable across rename operations. Controlled selection can open a document, while expandedIds tracks only the visual folder state.

Customization

FileTreeFolderProps.value
Required; string.
FileTreeFolderProps.name
Required; string.
FileTreeFolderProps.icon
Optional; ReactNode.
FileTreeFolderProps.disabled
Optional; boolean.
FileTreeFolderProps.children
Optional; ReactNode.
FileTreeFolderProps.className
Optional; string.
FileTreeFileProps.value
Required; string.
FileTreeFileProps.name
Required; string.
FileTreeFileProps.icon
Optional; ReactNode.
FileTreeFileProps.disabled
Optional; boolean.
FileTreeFileProps.className
Optional; string.
FileTreeProps.children
Required; ReactNode.
FileTreeProps.value
Optional; string | null.
FileTreeProps.defaultValue
Optional; string | null.

Integration notes

  • Selecting a file is not authorization to fetch or edit it; validate access in the application.
  • Handle removed or renamed files without leaving a selected ID pointing at a different document.

Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.

Better with your agent

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.

Connect to MCP