Skip to content

Tree view ​

A tree view draws a file tree: folders and files with icons, notes, badges and git status. Paste the output of tree or write the indentation yourself.

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview files "my-app" [sort: folders, chevrons] {
  src/
    index.ts: entry point
    components/ [collapsed]
      Button.tsx
    routes/
      [id]/
        page.tsx [added]
    util.ts [modified]
    legacy.js [deleted]
  package.json
  README.md [highlight]
  diagram.yu  # the source
}

Indentation is the tree, and there may be several top-level entries. - bullets are optional, and so are the ├──, │ and |-- prefixes the tree command prints, so its output pastes as is (the N directories, M files line is skipped). An entry is a folder when it has children, ends in / or says [folder], and a ... entry stands for "more files". Files get an icon and a colour from their name: code, tests, scripts, documents, images, fonts, media, config, lockfiles, packages, git files and databases. Folders such as node_modules/, dist/ and .git/ get a grey one.

name: note or name # note adds a note. The props go at the end of the line, after a space, so a folder named [id] stays a name:

entry propresult
a colourtints the icon and the name
icon: folder | code | doc | image | …another icon; any other text, like an emoji, is drawn as is
badge: texta pill after the name
note: texta note, like : text
size: texta right-aligned column, like 4 KB or 12 lines
collapseda closed folder: its children are hidden
highlighta band behind the row
dima faded row
folder / fileforces the entry's type
added, modified, deleted, renamed, ignoredgit status: colours the name and adds a letter on the right

The icon names are folder, folder-open, file, code, doc, image, config, lock, package, git, database, test, font, media, terminal and yuhwa.

Rules ​

match <glob> [props] gives every entry the glob matches the same props, so a tree can say once that tests are faded or that a folder starts closed. A rule may go anywhere in the body; the entry's own props win over a rule's.

globmatches
*.test.tsnames; * and ? never cross a /
src/**/*.tspaths, when the glob has a /; ** crosses /
*.{ts,tsx}either ending
docs/folders only, when the glob ends in /

A rule that matches nothing gets a warning.

header propresult
icons: color | mono | emoji | nonecoloured icons (default), grey ones, emoji, none
lines: solid | rounded | dashed | dotted | nonethe guide lines; rounded curves the corner to the last child
sort: none | name | foldersas written (default), by name, folders first
notes: column | inlinenotes in one aligned column (default) or after each name
chevronsa › before every folder
rows: stripedevery other row shaded
spacing: compact | normal | relaxedrow height (not the same as compact)
slashes: true | falseadd or remove the / after folder names
compacta folder whose only child is a folder shares its row: a/b/c/; a folder with a note, badge, status or other prop stays on its own
counts: collapsed | all | nonehow many entries a folder holds: closed ones (default)
marks: letter | dot | nonethe git status column on the right, set by added, modified, … : letters M, A, D, R (default), dots, or none
rollup: falseno dot on folders that hold changed files
depth: 2show only the first levels; deeper folders show closed
indent: 24the width of one level
folder-color: tealthe folder icons (default amber)
line-color, note-colorthe guide lines, the notes
highlight-color, badge-colorthe default highlight band and badge pill
strike-width: 2, strike-color: redthe line through deleted entries

The panel props work as on every panel: radius, shadow, border, background and frame: false style the frame. edge-color and edge-width draw the guide lines (line-color wins over edge-color), and radius also rounds the highlight band. width makes the frame at least that wide; the notes, sizes and marks then line up at its right edge.

Examples ​

Rules, counts and sizes ​

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview web "acme-web" [sort: folders, chevrons, compact, folder-color: teal] {
  match *.test.ts [dim]
  match docs/ [collapsed]
  src/
    main/
      java/
        App.java: entry point
    components/
      Button.tsx [added, size: 2.1 KB]
      Button.test.ts [size: 1.4 KB]
      Card.tsx [modified, size: 3.8 KB]
      ...
  docs/
    intro.md
    guide.md
  scripts/
    deploy.sh
  package.json
}

Folders that hold changed files get a dot in the status column; closed folders show how many entries they hide.

Rounded lines and a styled frame ​

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview src "src" [lines: rounded, compact, edge-color: teal, edge-width: 2, radius: 16, shadow] {
  main/
    java/
      com/
        acme/
          App.java [highlight]
          Router.java
  test/
    java/
      AppTest.java
}

compact puts main/java/com/acme/ and test/java/ on one row each.

Pasted tree output ​

The drawing characters and the summary line are skipped.

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview out "tree" {
  .
  ├── src
  │   ├── main.go
  │   └── handler.go
  ├── go.mod
  └── README.md

  1 directory, 4 files
}

A pull request ​

Statuses colour the names and add a letter on the right.

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview pr "feat: dark mode" [sort: folders] {
  src/
    theme/
      dark.ts [added]
      tokens.ts [modified]
    old-colors.ts [deleted]
    App.tsx [modified]
  .env [ignored]
  CHANGELOG.md [modified]
}

A monorepo, explained ​

Notes line up in one column; badges mark what matters.

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview repo "acme" [chevrons, rows: striped] {
  apps/
    web/: the Next.js site
    admin/: internal tools [badge: beta]
  packages/
    ui/: shared components
    config/: lint and tsconfig presets
  docs/ [collapsed]
    intro.md
  pnpm-workspace.yaml
  turbo.json: build pipeline
}

Plain ​

No icons, dashed lines, compact rows.

yuhwa diagramEdit
yuhwa
theme: mono

treeview plain "layout" [icons: none, lines: dashed, spacing: compact] {
  content/
    posts/
      hello.md
    about.md
  layouts/
    base.html
  config.toml
}

Emoji and your own icons ​

yuhwa diagramyuhwa diagramEdit
yuhwa
treeview fun "assets" [icons: emoji] {
  images/
    logo.svg
    hero.png
  fonts/ [icon: 🔤]
    Inter.woff2
  notes.txt [icon: 📝]
}

Released under the MIT License.