Jamdesk Documentation logo

Tree

Display file and folder hierarchies with interactive expand/collapse and keyboard navigation. Ideal for project structure documentation.

Tree displays file and folder hierarchies with interactive expand/collapse and full keyboard navigation. It's designed for documenting project structures, showing directory layouts, or explaining where files should go in a codebase.

Use Tree when:

  • Showing project structure for getting started guides
  • Explaining file organization in tutorials
  • Documenting CLI output that shows directory trees
  • Illustrating where to add files in configuration guides

Usage

<Tree>
  <TreeFolder name="src" defaultOpen>
    <TreeFile name="index.ts" />
  </TreeFolder>
</Tree>

Basic Tree

package.json
<Tree>
  <TreeFolder name="src" defaultOpen>
    <TreeFile name="index.ts" />
    <TreeFile name="config.ts" />
  </TreeFolder>
  <TreeFile name="package.json" />
</Tree>

Project Structure Example

Show readers what a project looks like after setup:

Tree vs Code Blocks

FeatureTreeCode block
InteractiveYes (expand/collapse)No
Keyboard navigationFull supportNo
Visual hierarchyIcons + indentationText only
Best forDocumentationQuick inline references

Use Tree for primary structure documentation. Use code blocks for quick inline references like "create src/index.ts".

Keyboard Navigation

The Tree component supports full keyboard navigation:

KeyAction
Arrow DownMove to next item
Arrow UpMove to previous item
Arrow RightExpand folder or move to first child
Arrow LeftCollapse folder or move to parent
HomeJump to first item
EndJump to last visible item
Enter / SpaceToggle folder expand/collapse
Type charactersJump to matching item

Props

TreeFolder

stringrequired

Folder name displayed in the tree.

booleandefault: false

Start in expanded state.

booleandefault: true

Whether the folder can be toggled.

TreeFile

stringrequired

File name displayed in the tree.

What's Next?

Components Overview

Browse all available components

MDX Basics

Learn how to use components in MDX