Skip to content

File trees

Show a folder structure with Tree, Tree.Folder and Tree.File.

Updated

A tree shows files and folders. Folders open and close.

  • docs
    • docs.json
    • guides
      • receive-webhooks.mdx
      • verify.mdx
  • theme.json
MDX
<Tree>
<Tree.Folder name="docs" defaultOpen>
<Tree.File name="docs.json" />
<Tree.Folder name="guides" defaultOpen>
<Tree.File name="receive-webhooks.mdx" />
<Tree.File name="verify.mdx" highlight />
</Tree.Folder>
</Tree.Folder>
<Tree.File name="theme.json" />
</Tree>

Folders are native disclosures, so they work by keyboard.

Tree takes no props.

namestring
The folder’s name.
defaultOpenbooleandefault: false
Starts the folder open.
openablebooleandefault: true

With openable={false}, the folder is a plain label with its files always shown, and can’t be closed.

highlightboolean
Marks the folder.
namestring
The file’s name.
highlightboolean
Marks the file.
Was this page helpful?

Report a problem

What’s the problem?

The docs team sees this. Other readers don’t.