Kanshō

Docs / Sandbox and code /

FileTree

Expandable file and directory tree with selection, status indicators, and nesting.

Preview

Variants

Expanded

Collapsed

Props

PropTypeDescription
nodes*FileNode[]Tree data. Folders carry optional children; files carry language and badge.
selectedIdstringThe currently selected node id (controlled).
onSelect(id: string) => voidCalled when any node is clicked.
density"comfortable" | "compact"Row height. Defaults to comfortable.
toolbarReact.ReactNodeOptional slot rendered above the tree (e.g. a search input).
classNamestringAdditional class names for the root element.

* required.

Usage

import { FileTree } from "@/components/sandbox/file-tree";

<FileTree
  nodes={[
    {
      id: "src",
      name: "src",
      kind: "folder",
      defaultOpen: true,
      children: [
        { id: "index", name: "index.ts", kind: "file", language: "ts", badge: "modified" },
      ],
    },
  ]}
  selectedId={selectedId}
  onSelect={setSelectedId}
/>