Skip to main content
To display the structure of a directory with files and collapsible subdirectories, use the <FileTree> component. Click on a subdirectory to open or close it. The <FileTree> is a wrapper over the built-in <Tree> component provided by Mintlify, but with a data-driven interface: pass a list of objects and strings instead of composing JSX children manually.

Import

Usage

Specify the structure of files and directories inside the items property as a JavaScript list of strings, objects, and nested lists.

Specify files and placeholders

Add notes and comments

Specify folders and their state

<FileTree> props

Implementation: filetree.jsx The <FileTree> component accepts the following props:

items (required)

type: FileTreeItem[] Hierarchy of files and folders to display. The FileTreeItem can be one of the following kinds:
  • ... or — both display a placeholder entry indicating additional items in a directory that are intentionally omitted
  • any string — name of the file inside the currently described directory
  • { kind: "file", ...fields... } — an extended syntax for files, with the following fields:
    • name: string — the filename;
    • note?: string — optional comment, displayed next to the filename;
  • { kind: "folder", ...fields... } — syntax for folders and directories, with the following fields:
    • name: string — the directory name;
    • note?: string — optional comment, displayed next to the directory name;
    • open?: boolean — whether to open the directory, defaults to true;
    • items: FileTreeItem[] — nested files and folders;

defaultOpen

type: boolean
default: true
Whether to open all folders on page load. Can be overridden by the open property of individual FileTreeItem entries.

Using <Tree> directly

For cases where a data-driven approach is unnecessary, use the built-in <Tree> component directly. It requires no import and accepts <Tree.File> and <Tree.Folder> sub-components as children.
app
layout.tsx
page.tsx
api
route.ts
package.json