Components

Tree

Hierarchical file and folder structures.

Use Tree (or its alias FileTree) to display file systems and project directories. Tree.Folder and Tree.File compose explicitly, or write a nested Markdown list inside the tree for quick static structures.

    • layout.tsx
    • page.tsx
    • global.css
  • package.json
  • tsconfig.json

Markdown list syntax#

Leave a blank line after the opening tag. A trailing slash (or nested items) marks a folder; folders with nested items expand by default.

    • index.mdx
      • configuration.mdx
  • docs.config.ts

Highlight the active path#

    • layout.tsx
    • page.tsx
  • package.json

Set --tree-highlight on the Tree style to override the tint.

Folders support arrow-key navigation: up/down moves, right expands, left collapses, * expands siblings, typing jumps to a name.

Properties#

Tree / FileTree#

NameTypeDescription
childrenReactNode

Tree.Folder / Tree.File nodes, or a Markdown list.

Tree.Folder#

NameTypeDescription
namerequiredstring

Folder name shown in the tree.

defaultOpenboolean

Whether the folder expands by default.

Default: false
openableboolean

Set to false for non-interactive folders.

Default: true
highlightboolean

Tint the folder as the active path.

Default: false

Tree.File#

NameTypeDescription
namerequiredstring

File name shown in the tree.

highlightboolean

Tint the file as the active item.

Default: false
Last updated on