✦ StealThis .dev

Wiki — Collapsible Doc Tree Nav

A dev-docs style collapsible documentation tree sidebar with nested sections, expand and collapse chevrons, indented child links, and a current-page highlight. A sticky filter box live-searches the tree, auto-expands matching branches, and highlights matched text. Keyboard arrows move between visible rows and Enter opens a page. On small screens the sidebar becomes a slide-in drawer beside a readable serif article column.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Collapsible Doc Tree Nav

A documentation shell modeled on developer reference sites. A persistent left sidebar holds a nested doc tree — Getting started, Guides, API reference, Reference — where parent sections expand and collapse with a rotating chevron, child links sit on indented guide lines, and the current page keeps an accented highlight with an aria-current marker. The centered article column uses a serif body for long-form prose, callouts, tables, and code blocks, and a sticky right-rail table of contents tracks your scroll position.

A sticky search box at the top of the sidebar live-filters the tree as you type: matching branches auto-expand, the matched substring is highlighted with a <mark>, non-matching rows hide, and a running result count updates. Press / anywhere to jump into the filter, use ↑ and ↓ to walk the visible rows, Enter to open the focused page, and Esc to clear. Tree rows themselves are keyboard operable too, with left and right arrows collapsing and expanding a focused section.

Everything is self-contained vanilla JS with no dependencies. Below the breakpoint the sidebar turns into a slide-in drawer triggered by the header button, dimming the page with a scrim that closes on click or Esc. A small toast() helper confirms navigation, the layout reflows down to about 360px, and focus styles plus reduced-motion handling keep it accessible.

Illustrative UI only — fictional articles, products, and data.