Skip to content
Playground

File Tree

Nested folders and files with disclosure carets and indented children.

File Tree presents a small explorer hierarchy. A folder discloses its children. A file is a label in that hierarchy.

Explorer

button.tsx
card.tsx
package.json
TSX
import { FileTree } from "@zentara-co/zenos-ui";
TSX
<FileTree.Root>  <FileTree.Folder label="src" defaultOpen>    <FileTree.File label="index.ts" />    <FileTree.Folder label="lib">      <FileTree.File label="utils.ts" />    </FileTree.Folder>  </FileTree.Folder>  <FileTree.File label="package.json" /></FileTree.Root>
FileTree.Root├── FileTree.Folder│   ├── FileTree.File│   └── FileTree.Folder└── FileTree.File

Folders may be empty. Nesting is the children of FileTree.Folder, so a closed folder hides every row inside it.

Each row includes a folder or file glyph. Pass icon to replace that glyph with your own, or icon={null} to remove it. The disclosure caret stays on the folder trigger.

defaultOpen sets the initial uncontrolled state. Use open and onOpenChange when another part of the interface must read or drive a folder. disabled keeps the folder visible and prevents it from opening.

FileTree.Root
FileTree.Folder
FileTree.File

API

PropTypeDefaultDescription
Folder.label ReactNode — Folder name and trigger label.
Folder.icon ReactNode | null — Replaces the folder glyph. null removes it.
Folder.defaultOpen boolean false Initial uncontrolled open state.
Folder.open boolean — Controlled open state.
Folder.onOpenChange (open: boolean, eventDetails) => void — Runs when the folder opens or closes.
Folder.disabled boolean false Keeps the folder closed and prevents activation.
File.label ReactNode — Visible file name.
File.icon ReactNode | null — Replaces the file glyph. null removes it.
native props React.HTMLAttributes<HTMLElement> — Forwards native attributes, events, aria-*, data-*, className, style, and ref.

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

A folder trigger is a button and exposes aria-expanded. Enter and Space toggle it. File rows are text, not controls, so they are not in the tab order. Decorative glyphs are hidden from assistive technology. Motion-reduction preferences disable the caret rotation and the height transition.

Use Collapsible when the region is a single disclosure rather than a file hierarchy.