Skip to content

ExpressiveCSS

Browse documentation

Tree

Nested lists of folders and links that open in place, for file browsers and deep navigation.

View as Markdown

On this page

Use a <ul class="tree"> of nested lists for file browsers and deep navigation. Each branch is a <details>, and its <summary> is the row. Each leaf is a link.

Mark the current row with aria-current. Each level draws a guide line down from its parent's chevron. Wrap a tree of links in a named <nav>.

<nav aria-label="Files">
  <ul class="tree">
    <li>
      <details open>
        <summary>src</summary>
        <ul>
          <li><a href="/src/index.ts" aria-current="page">index.ts</a></li>
          <li>
            <details>
              <summary>components</summary>
              <ul>
                <li><a href="/src/components/menu.ts">menu.ts</a></li>
              </ul>
            </details>
          </li>
        </ul>
      </details>
    </li>
    <li><a href="/README.md">README.md</a></li>
  </ul>
</nav>

Keyboard

The rows are native disclosures and links, so every row is a Tab stop and Enter or Space opens a branch. Don't add role="tree". That role promises arrow-key navigation between rows, and native disclosures don't provide it.

Tokens

Override these on the .tree.

Token Default
--md-comp-tree-row-height40px
--md-comp-tree-row-shape100px
--md-comp-tree-guide-color--md-sys-color-outline-variant
--md-comp-tree-selected-container-color--md-sys-color-secondary-container

No matching pages

  • Source color

    The seed every generated ramp derives from. Pick one and browse the docs — the whole theme follows. Error does not: it is a fixed hue.

    Default source: Mist Iris.

    ExpressiveCSS presets: Lagoon, Harbor, Breeze, Cobalt, Iris.

    Bold

    Soft

    Mist

    Glow