File Tree

A component for displaying a file tree

Default
Default file tree
src
app
layout.tsx
page.tsx
globals.css
api
auth
route.ts
users
route.ts
components
ui
button.tsx
card.tsx
file-tree.tsx
header.tsx
footer.tsx
lib
utils.ts
constants.ts
hooks
use-auth.ts
use-theme.ts
public
favicon.ico
logo.svg
images
hero.png
avatar.jpg
package.json
tsconfig.json
next.config.mjs
tailwind.config.ts
.env.local
.gitignore
README.md
1import { FileTreeDefault } from "@/components/examples/file-tree-examples"
2
3<FileTreeDefault />
Bordered
Bordered file tree
package.json
tsconfig.json
next.config.mjs
tailwind.config.ts
.env.local
.gitignore
README.md
1import { FileTreeBordered } from "@/components/examples/file-tree-examples"
2
3<FileTreeBordered />
Elevated
Elevated file tree
package.json
tsconfig.json
next.config.mjs
tailwind.config.ts
.env.local
.gitignore
README.md
1import { FileTreeElevated } from "@/components/examples/file-tree-examples"
2
3<FileTreeElevated />
Ghost + Large Size
Ghost file tree with large size
package.json
tsconfig.json
next.config.mjs
tailwind.config.ts
.env.local
.gitignore
README.md
1import { FileTreeGhost } from "@/components/examples/file-tree-examples"
2<div>
3 <FileTreeGhost
4 data={sampleData}
5 size="lg"
6 />
7</div>

Props

NameTypeDefaultDescription
dataFileTreeNode[][]The data to display in the file tree
variant"default" | "ghost" | "bordered" | "elevated"defaultThe variant of the file tree
size"sm" | "default" | "lg"defaultThe size of the file tree
defaultExpandedbooleantrueWhether the file tree is expanded by default
onSelect() => voidundefinedCallback when a file or folder is selected
selectedPathstringundefinedThe selected path in the file tree
onExpand() => voidundefinedCallback when a file or folder is expanded
onCollapse() => voidundefinedCallback when a file or folder is collapsed