TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mintlify/components/llms.txt
Use this file to discover all available pages before exploring further.
Tree component renders an interactive, accessible file tree view with support for expandable folders, keyboard navigation, and type-ahead search.
Usage
Tree Root Props
The tree content, typically a combination of
Tree.File and Tree.Folder components.Additional CSS classes to apply to the tree root container.
Tree.Folder Props
The display name of the folder.
Whether the folder should be expanded by default.
The contents of the folder (nested files and folders).
Whether the folder can be opened/closed. If
false or if there are no children, the folder cannot be expanded.Tree.File Props
The display name of the file.
Keyboard Navigation
The Tree component implements the WAI-ARIA tree pattern with full keyboard support:- Arrow Down: Move focus to the next visible tree item
- Arrow Up: Move focus to the previous visible tree item
- Arrow Right: If focused on a folder:
- If collapsed, expand the folder
- If expanded, move focus to the first child
- Arrow Left: If focused on a folder:
- If expanded, collapse the folder
- If collapsed, move focus to the parent folder
- Home: Move focus to the first tree item
- End: Move focus to the last visible tree item
- Enter or Space: Activate the focused item (toggle folder or activate file)
- *****: Expand all sibling folders at the current level
- Type-ahead: Type any character to jump to the next item starting with that character
- Continues building search string if typed within 500ms
- Searches in a circular manner through all visible items
Examples
Basic File Tree
Folders Expanded by Default
Deeply Nested Structure
Files Only (Flat List)
Empty and Non-Openable Folders
Complete Project Structure
With Custom Styling
Long File Names (Automatic Truncation)
Behavior
- Roving Tab Index: Only one tree item is focusable at a time (tab index management)
- Type-ahead Search: Accumulates typed characters within 500ms to search for matching items
- Circular Navigation: Type-ahead search wraps around to the beginning after reaching the end
- Visual Indicators:
- Closed folders show a folder icon
- Open folders show an open folder icon
- Files show a file icon
- Indentation: Each nesting level increases indentation by a calculated amount
- Visual Hierarchy: Connecting lines show parent-child relationships for expanded folders
Accessibility
- ARIA Role: Tree uses
role="tree", folders and files userole="treeitem" - ARIA Properties:
aria-expanded: Indicates folder open/closed statearia-level: Indicates nesting deptharia-selected: Indicates selection state (always false by default)aria-owns: Links folders to their child groups
- ARIA Label: Tree has default
aria-label="File tree" - Keyboard Support: Full keyboard navigation following WAI-ARIA tree pattern
- Focus Management: Proper focus and tabindex management for keyboard users
Source
View the source code:- Tree Root:
packages/components/src/components/tree/root.tsx:26 - Tree Folder:
packages/components/src/components/tree/folder.tsx:10 - Tree File:
packages/components/src/components/tree/file.tsx:9