FileTree component provides a beautiful way to display project file structures, directory hierarchies, and file organization in your documentation. It renders a static tree view with Lucide icons, optional descriptions, and badges in a clean code-block styled interface.
Basic Usage
Import the component and pass it a hierarchical structure of files and directories.FileTree usage
Basic FileTree Example
Features
Visual Design
- Code block styling with rounded corners and syntax highlighting appearance
- Dark mode support with automatic theme switching
- Vertical guide lines for nested directory structures
- Consistent spacing and typography for optimal readability
File Icons
- Folder icons for directories (📁)
- File icons for individual files (📄)
- Icon customization via the
getFileIconfunction (extensible for different file types)
Metadata Support
- Descriptions provide context for files and directories
- Badges highlight important files with customizable colors
- Hierarchical structure supports unlimited nesting depth
Advanced Example
Here’s a comprehensive example showing a typical project structure with various file types and metadata:Preview
Properties
Hierarchical array of files and directories to display. Each item should have a
name property.Optional title displayed at the top of the file tree component
Maximum nesting depth to prevent infinite recursion in deeply nested structures
Whether to display file and folder icons next to items
FileTreeItem Interface
Each item in thestructure array should follow this interface:
FileTreeGroup
UseFileTreeGroup to organize multiple related file trees:
Preview
Best Practices
Use Descriptive Names
Use Descriptive Names
Choose clear, descriptive names for files and directories that immediately convey their purpose.
Add Context with Descriptions
Add Context with Descriptions
Use descriptions to provide additional context that helps users understand the purpose and contents of files/directories.
Use Badges Strategically
Use Badges Strategically
Apply badges to highlight important files, configuration files, or items that need special attention.
Group Related Items
Group Related Items
Keep Depth Reasonable
Keep Depth Reasonable
While FileTree supports unlimited nesting, limit depth to 4-5 levels for readability. Consider breaking very deep structures into separate documentation sections.
Styling and Theming
FileTree automatically adapts to Mintlify’s light and dark themes:- Light mode: Light gray backgrounds with dark text
- Dark mode: Dark backgrounds with light text
- Code block styling: Consistent with other code elements in your documentation
- Vertical guide lines: Subtle visual indicators for nested structures
- Hover states: Clean interaction feedback
- Typography: Monospace font for file names, proportional font for descriptions
Troubleshooting
Component not found
Component not found
If you see
Cannot find module "/snippets/FileTree.jsx":- Ensure FileTree.jsx exists in your
docs/snippets/folder - Run
mint-tsdocsto auto-install the component - Check that the import path is correct (should start with
/snippets/)
Icons not displaying
Icons not displaying
If file/folder icons are not showing:
- Verify that Mintlify’s Icon component is available
- Check browser console for JavaScript errors
- Ensure
showIconsprop is not set tofalse
Structure not rendering
Structure not rendering
If the file tree doesn’t display correctly:
- Verify that each item has a
nameproperty - Check that the
structureprop is a valid array - Ensure proper JSON formatting in your MDX file
Styling issues
Styling issues
If the component doesn’t look right:
- Ensure Tailwind CSS is properly loaded in your Mintlify site
- Check that you’re using an up-to-date version of the component
- Try refreshing the page to reload styles
Version History
v3.0.0
Initial release with hierarchical file structure visualization, Lucide icons, and code block styling
Future
- File type detection with specific icons for different extensions
- Expandable/collapsible directories
- File size and modification date display
- Copy file paths functionality

