VitePress Plugin Folder Tree
A plugin for VitePress — render beautiful, interactive file/folder tree diagrams from YAML in markdown code blocks.
Quick Start
- locales1 folder, 3 files
- pages2 folders
- index3 files
- en.json
- fr.json
- ar.json
- about3 files
- en.json
- fr.json
- ar.json
- en.json
- fr.json
- ar.json
Code:
yaml
```tree
- name: locales
children:
- name: pages
children:
- name: index
children:
- en.json
- fr.json
- ar.json
- name: about
children:
- en.json
- fr.json
- ar.json
- en.json
- fr.json
- ar.json
```Features
- YAML format — structured, readable, easy to maintain
- Interactive — Click folders to expand/collapse
- Search & filter — Find files instantly in large trees
- Copy as text — Copy tree structure as ASCII art to clipboard
- Clickable links —
hreffield makes items navigate to URLs - Tree guide lines — Vertical connectors for clear hierarchy
- Lockable —
locked: trueprevents toggling a folder - Metadata —
descriptionbadge,noteright-aligned text,highlight,icon - Initial state —
open: falsestarts folder collapsed, globaldefaultOpen - Toolbar — Expand all / Collapse all / Copy / Search (hideable with
showToolbar: false) - Static mode —
interactive: falserenders a snapshot with no toggling - Validation — Clear YAML error messages at build time
- Dark Mode — Full VitePress theme support
Installation
bash
pnpm add vitepress-plugin-folder-treeSetup
1. VitePress config — .vitepress/config.mts:
ts
import { defineConfig } from 'vitepress'
import { withFolderTree } from 'vitepress-plugin-folder-tree'
export default withFolderTree(defineConfig({
title: "My Site",
}))2. Import styles — .vitepress/theme/index.ts:
ts
import DefaultTheme from 'vitepress/theme'
import 'vitepress-plugin-folder-tree/style.css'
export default {
extends: DefaultTheme,
}CSS is shipped as a separate file for better performance, caching, and CSP compatibility.
All Node Fields Demo
- projectRootv1.0
- src2 folders, 1 file
- coreDo not modify
- engine.ts
- runtime.ts
- features3 files3 modules
- auth.ts
- billing.ts
- notifications.ts
- index.tsentrypointupdated today
- distAuto-generated
- .envsecret
- package.json
- README.md
Links Demo
Items with href become clickable links:
- docs1 folder, 2 files
- getting-started.mdStart here
- api-reference.mdfull API
- examples2 files
Check out the Examples page for more.