---
title: "Tree View"
description: "Tree View component - hierarchical data display with expand/collapse."
slug: "tree-view"
---

import { DocPage, PageHeader, SkillPanel, Example, ExampleLabel, ExampleHint, ExampleCode, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeCard, TableCard, ApiSection } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="tree-view" title="Tree View" component="tree-view">
  A hierarchical tree for browsing nested data like file systems. Uses native <code>&lt;details&gt;</code> for expand/collapse with ARIA tree roles.
</PageHeader>

<SkillPanel component="tree-view">
  <SkillField label="Native basis">
<SkillText>Nested <code>&lt;ul&gt;</code> elements with <code>role="tree"</code> / <code>role="treeitem"</code> ARIA pattern for hierarchical data.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul" title="nested list structure"><code>&lt;ul&gt;</code></ApiPill>
    <ApiPill href="https://www.w3.org/WAI/ARIA/apg/patterns/treeview/" title="ARIA tree roles and keyboard navigation"><code>Tree View WAI-ARIA pattern</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details" title="native expand/collapse for branches"><code>&lt;details&gt;</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.tree</code>
    <code>.tree-group</code>
    <code>.tree-item</code>
    <code>.tree-branch</code>
    <code>.tree-branch-trigger</code>
    <code>.tree-leaf</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Accessibility">
<SkillText dense>• Root <code>&lt;ul&gt;</code> has <code>role="tree"</code> and <code>aria-label</code></SkillText>
  <SkillText dense>• Branch items have <code>role="treeitem"</code> and <code>aria-expanded</code></SkillText>
  <SkillText dense>• Leaf items have <code>role="treeitem"</code> without <code>aria-expanded</code></SkillText>
  <SkillText dense>• Nested groups use <code>role="group"</code></SkillText>
  <SkillText dense>• <code>data-selectable</code> tree: <code>aria-selected</code> on every operable item, click / Enter / Space selects, <code>tree-select</code> event</SkillText>
  <SkillText dense>• <code>aria-disabled="true"</code> items stay focusable but can't be opened, selected or followed</SkillText>
  <p class="text-muted-foreground m-0">• Keyboard: Arrow keys navigate, Enter/Space toggles branches (and selects in a selectable tree)</p>
  </SkillField>
</SkillPanel>

```html example label="File Explorer" hint="Nested tree with folders and files."
<div style="max-width: 18rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="File explorer">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0">
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path>
          </svg>
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path>
          </svg>
          <span>src</span>
        </summary>
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem" aria-expanded="false">
            <details class="tree-branch">
              <summary class="tree-branch-trigger" tabindex="0">
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path>
                </svg>
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path>
                </svg>
                <span>components</span>
              </summary>
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem">
                  <span class="tree-leaf" tabindex="0">
                    <svg
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
                    </svg>
                    <span>button.tsx</span>
                  </span>
                </li>
                <li class="tree-item" role="treeitem">
                  <span class="tree-leaf" tabindex="0">
                    <svg
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
                    </svg>
                    <span>card.tsx</span>
                  </span>
                </li>
              </ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem">
            <span class="tree-leaf" tabindex="0">
              <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
              </svg>
              <span>index.ts</span>
            </span>
          </li>
          <li class="tree-item" role="treeitem">
            <span class="tree-leaf" tabindex="0">
              <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
              </svg>
              <span>globals.css</span>
            </span>
          </li>
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem">
      <span class="tree-leaf" tabindex="0">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
        </svg>
        <span>package.json</span>
      </span>
    </li>
    <li class="tree-item" role="treeitem">
      <span class="tree-leaf" tabindex="0">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
        </svg>
        <span>README.md</span>
      </span>
    </li>
  </ul>
</div>
```

```html example label="Guidelines" hint="data-variant='guides' on the tree root draws a vertical guideline under every open folder, so the depth of nesting reads at a glance. The guideline of the level that holds keyboard focus darkens."
<div style="max-width: 18rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" data-variant="guides" role="tree" aria-label="Project files">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>src</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><span>components</span></summary
              >
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem" aria-expanded="true">
                  <details class="tree-branch" open>
                    <summary class="tree-branch-trigger" tabindex="0"
                      ><svg
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="m9 18 6-6-6-6"></path></svg
                      ><svg
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path
                          d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                        ></path></svg
                      ><span>ui</span></summary
                    >
                    <ul class="tree-group" role="group">
                      <li class="tree-item" role="treeitem">
                        <span class="tree-leaf" tabindex="0"
                          ><svg
                            xmlns="http://www.w3.org/2000/svg"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                          >
                            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                          ><span>button.tsx</span></span
                        >
                      </li>
                      <li class="tree-item" role="treeitem">
                        <span class="tree-leaf" tabindex="0"
                          ><svg
                            xmlns="http://www.w3.org/2000/svg"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                          >
                            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                          ><span>card.tsx</span></span
                        >
                      </li>
                      <li class="tree-item" role="treeitem">
                        <span class="tree-leaf" tabindex="0"
                          ><svg
                            xmlns="http://www.w3.org/2000/svg"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                          >
                            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                          ><span>dialog.tsx</span></span
                        >
                      </li>
                    </ul>
                  </details>
                </li>
                <li class="tree-item" role="treeitem" aria-expanded="true">
                  <details class="tree-branch" open>
                    <summary class="tree-branch-trigger" tabindex="0"
                      ><svg
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="m9 18 6-6-6-6"></path></svg
                      ><svg
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path
                          d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                        ></path></svg
                      ><span>forms</span></summary
                    >
                    <ul class="tree-group" role="group">
                      <li class="tree-item" role="treeitem">
                        <span class="tree-leaf" tabindex="0"
                          ><svg
                            xmlns="http://www.w3.org/2000/svg"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                          >
                            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                          ><span>input.tsx</span></span
                        >
                      </li>
                      <li class="tree-item" role="treeitem">
                        <span class="tree-leaf" tabindex="0"
                          ><svg
                            xmlns="http://www.w3.org/2000/svg"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                          >
                            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                          ><span>select.tsx</span></span
                        >
                      </li>
                    </ul>
                  </details>
                </li>
                <li class="tree-item" role="treeitem">
                  <span class="tree-leaf" tabindex="0"
                    ><svg
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><span>header.tsx</span></span
                  >
                </li>
              </ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><span>lib</span></summary
              >
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem">
                  <span class="tree-leaf" tabindex="0"
                    ><svg
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><span>utils.ts</span></span
                  >
                </li>
                <li class="tree-item" role="treeitem">
                  <span class="tree-leaf" tabindex="0"
                    ><svg
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><span>format.ts</span></span
                  >
                </li>
              </ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem">
            <span class="tree-leaf" tabindex="0"
              ><svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>index.ts</span></span
            >
          </li>
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="false">
      <details class="tree-branch">
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>public</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem">
            <span class="tree-leaf" tabindex="0"
              ><svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>favicon.ico</span></span
            >
          </li>
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem">
      <span class="tree-leaf" tabindex="0"
        ><svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
        ><span>package.json</span></span
      >
    </li>
    <li class="tree-item" role="treeitem">
      <span class="tree-leaf" tabindex="0"
        ><svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
        ><span>README.md</span></span
      >
    </li>
  </ul>
</div>
```

```html example label="Checkboxes with emojis, independent" hint="data-checkable='independent' keeps every box on its own (no cascade) - a permissions list where a group can be granted without its members. Emojis stand in for icons."
<div style="max-width: 20rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Permissions" data-checkable="independent">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><span aria-hidden="true">📁</span
          ><input type="checkbox" class="checkbox tree-check" name="perm" value="projects" /><span
            >Projects</span
          ></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><span aria-hidden="true">👀</span
              ><input type="checkbox" class="checkbox tree-check" name="perm" value="read" checked /><span
                >Read</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><span aria-hidden="true">✏️</span
              ><input type="checkbox" class="checkbox tree-check" name="perm" value="write" /><span>Write</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><span aria-hidden="true">🗑️</span
              ><input type="checkbox" class="checkbox tree-check" name="perm" value="delete" /><span>Delete</span></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><span aria-hidden="true">💳</span
          ><input type="checkbox" class="checkbox tree-check" name="perm" value="billing" /><span
            >Billing</span
          ></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><span aria-hidden="true">🧾</span
              ><input type="checkbox" class="checkbox tree-check" name="perm" value="view-invoices" checked /><span
                >View invoices</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><span aria-hidden="true">🔁</span
              ><input type="checkbox" class="checkbox tree-check" name="perm" value="change-plan" checked /><span
                >Change plan</span
              ></span
            ></li
          >
        </ul>
      </details>
    </li>
  </ul>
</div>
```

```html example label="Checkboxes and drag and drop" hint="Both at once: pick items and sort them. Moving an item re-derives the folders' checkbox states."
<div style="max-width: 20rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Backlog" data-checkable data-sortable>
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><input type="checkbox" class="checkbox tree-check" name="task" value="sprint-12" /><span
            >Sprint 12</span
          ></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="task" value="login-flow" checked /><span
                >Login flow</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="task" value="dark-mode" /><span
                >Dark mode</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="task" value="export-csv" /><span
                >Export CSV</span
              ></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><input type="checkbox" class="checkbox tree-check" name="task" value="later" /><span>Later</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="task" value="offline-mode" /><span
                >Offline mode</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="task" value="themes" /><span>Themes</span></span
            ></li
          >
        </ul>
      </details>
    </li>
  </ul>
</div>
```

```html example label="Disabled items" hint="aria-disabled='true' on a treeitem dims the row and makes it inert: a disabled folder can't be opened (click, Enter, Space, ArrowRight), a disabled row can't be selected or followed. It stays in the arrow-key path, so screen-reader users still learn it exists."
<div style="max-width: 18rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Workspace" data-selectable>
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><span>Workspace</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"><span>Roadmap.md</span></span></li
          >
          <li class="tree-item" role="treeitem" aria-expanded="false" aria-disabled="true">
            <details class="tree-branch">
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <rect width="18" height="11" x="3" y="11" rx="2" ry="2"></rect>
                  <path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg
                ><span>Legal (restricted)</span></summary
              >
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem"
                  ><span class="tree-leaf" tabindex="0"><span>Contract.pdf</span></span></li
                >
              </ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem" aria-disabled="true"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <rect width="18" height="11" x="3" y="11" rx="2" ry="2"></rect>
                <path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg
              ><span>Budget.xlsx (locked)</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"><span>Notes.md</span></span></li
          >
        </ul>
      </details>
    </li>
  </ul>
</div>
```

```html example label="Deep nesting" hint="Eight levels in a 20rem frame, with guides so each level stays traceable. Every level indents 1.25rem; labels that run out of room truncate with an ellipsis instead of overflowing - keep the full text in title for hover and assistive tech."
<div style="max-width: 20rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Infrastructure" data-variant="guides">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>Company</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><span>Engineering</span></summary
              >
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem" aria-expanded="true">
                  <details class="tree-branch" open>
                    <summary class="tree-branch-trigger" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="m9 18 6-6-6-6"></path></svg
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path
                          d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                        ></path></svg
                      ><span>Platform</span></summary
                    >
                    <ul class="tree-group" role="group">
                      <li class="tree-item" role="treeitem" aria-expanded="true">
                        <details class="tree-branch" open>
                          <summary class="tree-branch-trigger" tabindex="0"
                            ><svg
                              aria-hidden="true"
                              xmlns="http://www.w3.org/2000/svg"
                              viewBox="0 0 24 24"
                              fill="none"
                              stroke="currentColor"
                              stroke-width="2"
                              stroke-linecap="round"
                              stroke-linejoin="round"
                            >
                              <path d="m9 18 6-6-6-6"></path></svg
                            ><svg
                              aria-hidden="true"
                              xmlns="http://www.w3.org/2000/svg"
                              viewBox="0 0 24 24"
                              fill="none"
                              stroke="currentColor"
                              stroke-width="2"
                              stroke-linecap="round"
                              stroke-linejoin="round"
                            >
                              <path
                                d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                              ></path></svg
                            ><span>Infrastructure</span></summary
                          >
                          <ul class="tree-group" role="group">
                            <li class="tree-item" role="treeitem" aria-expanded="true">
                              <details class="tree-branch" open>
                                <summary class="tree-branch-trigger" tabindex="0"
                                  ><svg
                                    aria-hidden="true"
                                    xmlns="http://www.w3.org/2000/svg"
                                    viewBox="0 0 24 24"
                                    fill="none"
                                    stroke="currentColor"
                                    stroke-width="2"
                                    stroke-linecap="round"
                                    stroke-linejoin="round"
                                  >
                                    <path d="m9 18 6-6-6-6"></path></svg
                                  ><svg
                                    aria-hidden="true"
                                    xmlns="http://www.w3.org/2000/svg"
                                    viewBox="0 0 24 24"
                                    fill="none"
                                    stroke="currentColor"
                                    stroke-width="2"
                                    stroke-linecap="round"
                                    stroke-linejoin="round"
                                  >
                                    <path
                                      d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                                    ></path></svg
                                  ><span>Networking</span></summary
                                >
                                <ul class="tree-group" role="group">
                                  <li class="tree-item" role="treeitem" aria-expanded="true">
                                    <details class="tree-branch" open>
                                      <summary class="tree-branch-trigger" tabindex="0"
                                        ><svg
                                          aria-hidden="true"
                                          xmlns="http://www.w3.org/2000/svg"
                                          viewBox="0 0 24 24"
                                          fill="none"
                                          stroke="currentColor"
                                          stroke-width="2"
                                          stroke-linecap="round"
                                          stroke-linejoin="round"
                                        >
                                          <path d="m9 18 6-6-6-6"></path></svg
                                        ><svg
                                          aria-hidden="true"
                                          xmlns="http://www.w3.org/2000/svg"
                                          viewBox="0 0 24 24"
                                          fill="none"
                                          stroke="currentColor"
                                          stroke-width="2"
                                          stroke-linecap="round"
                                          stroke-linejoin="round"
                                        >
                                          <path
                                            d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                                          ></path></svg
                                        ><span>Edge</span></summary
                                      >
                                      <ul class="tree-group" role="group">
                                        <li class="tree-item" role="treeitem" aria-expanded="true">
                                          <details class="tree-branch" open>
                                            <summary class="tree-branch-trigger" tabindex="0"
                                              ><svg
                                                aria-hidden="true"
                                                xmlns="http://www.w3.org/2000/svg"
                                                viewBox="0 0 24 24"
                                                fill="none"
                                                stroke="currentColor"
                                                stroke-width="2"
                                                stroke-linecap="round"
                                                stroke-linejoin="round"
                                              >
                                                <path d="m9 18 6-6-6-6"></path></svg
                                              ><svg
                                                aria-hidden="true"
                                                xmlns="http://www.w3.org/2000/svg"
                                                viewBox="0 0 24 24"
                                                fill="none"
                                                stroke="currentColor"
                                                stroke-width="2"
                                                stroke-linecap="round"
                                                stroke-linejoin="round"
                                              >
                                                <path
                                                  d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                                                ></path></svg
                                              ><span>Europe</span></summary
                                            >
                                            <ul class="tree-group" role="group">
                                              <li class="tree-item" role="treeitem" aria-expanded="true">
                                                <details class="tree-branch" open>
                                                  <summary class="tree-branch-trigger" tabindex="0"
                                                    ><svg
                                                      aria-hidden="true"
                                                      xmlns="http://www.w3.org/2000/svg"
                                                      viewBox="0 0 24 24"
                                                      fill="none"
                                                      stroke="currentColor"
                                                      stroke-width="2"
                                                      stroke-linecap="round"
                                                      stroke-linejoin="round"
                                                    >
                                                      <path d="m9 18 6-6-6-6"></path></svg
                                                    ><svg
                                                      aria-hidden="true"
                                                      xmlns="http://www.w3.org/2000/svg"
                                                      viewBox="0 0 24 24"
                                                      fill="none"
                                                      stroke="currentColor"
                                                      stroke-width="2"
                                                      stroke-linecap="round"
                                                      stroke-linejoin="round"
                                                    >
                                                      <path
                                                        d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                                                      ></path></svg
                                                    ><span>Frankfurt</span></summary
                                                  >
                                                  <ul class="tree-group" role="group">
                                                    <li class="tree-item" role="treeitem"
                                                      ><span class="tree-leaf" tabindex="0"
                                                        ><svg
                                                          aria-hidden="true"
                                                          xmlns="http://www.w3.org/2000/svg"
                                                          viewBox="0 0 24 24"
                                                          fill="none"
                                                          stroke="currentColor"
                                                          stroke-width="2"
                                                          stroke-linecap="round"
                                                          stroke-linejoin="round"
                                                        >
                                                          <path
                                                            d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"
                                                          ></path>
                                                          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                                                        ><span title="fra-edge-01.production.internal.example.com"
                                                          >fra-edge-01.production.internal.example.com</span
                                                        ></span
                                                      ></li
                                                    >
                                                    <li class="tree-item" role="treeitem"
                                                      ><span class="tree-leaf" tabindex="0"
                                                        ><svg
                                                          aria-hidden="true"
                                                          xmlns="http://www.w3.org/2000/svg"
                                                          viewBox="0 0 24 24"
                                                          fill="none"
                                                          stroke="currentColor"
                                                          stroke-width="2"
                                                          stroke-linecap="round"
                                                          stroke-linejoin="round"
                                                        >
                                                          <path
                                                            d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"
                                                          ></path>
                                                          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                                                        ><span title="fra-edge-02.production.internal.example.com"
                                                          >fra-edge-02.production.internal.example.com</span
                                                        ></span
                                                      ></li
                                                    >
                                                  </ul>
                                                </details>
                                              </li>
                                            </ul>
                                          </details>
                                        </li>
                                      </ul>
                                    </details>
                                  </li>
                                </ul>
                              </details>
                            </li>
                          </ul>
                        </details>
                      </li>
                    </ul>
                  </details>
                </li>
              </ul>
            </details>
          </li>
        </ul>
      </details>
    </li>
  </ul>
</div>
```

```html example label="Empty branch" hint="A folder with no children keeps its role='group' list empty; the tree shows a muted placeholder row instead of opening onto nothing. The text defaults to 'Empty' - set data-empty on the .tree-group for your own wording."
<div style="max-width: 18rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Reports">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>Reports</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><span>Drafts</span></summary
              >
              <ul class="tree-group" role="group"></ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><span>Q4 2026</span></summary
              >
              <ul class="tree-group" role="group" data-empty="No reports yet"></ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Q3 2026.pdf</span></span
            ></li
          >
        </ul>
      </details>
    </li>
  </ul>
</div>
```

```html example label="Selection" hint="Add data-selectable to the tree root: a click, Enter or Space selects the row (aria-selected='true' - a primary-tinted surface and medium weight). A folder toggles AND selects. Every choice fires a bubbling tree-select event with the treeitem in detail.item."
<div style="max-width: 18rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Mail folders" data-selectable id="mail-tree">
    <li class="tree-item" role="treeitem" aria-selected="true"
      ><span class="tree-leaf" tabindex="0"><span>Inbox</span></span></li
    >
    <li class="tree-item" role="treeitem"
      ><span class="tree-leaf" tabindex="0"><span>Drafts</span></span></li
    >
    <li class="tree-item" role="treeitem"
      ><span class="tree-leaf" tabindex="0"><span>Sent</span></span></li
    >
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><span>Archive</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"><span>2025</span></span></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"><span>2024</span></span></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem"
      ><span class="tree-leaf" tabindex="0"><span>Trash</span></span></li
    >
  </ul>
</div>
<p class="text-sm text-muted-foreground" style="margin: 0.75rem 0 0"
  >Selected: <output id="mail-selected">Inbox</output></p
>
<script>
  document.getElementById('mail-tree').addEventListener('tree-select', (e) => {
    document.getElementById('mail-selected').textContent = e.detail.item.querySelector('span:last-child').textContent;
  });
</script>
```

```html example label="Checkboxes" hint="data-checkable on the tree: a .tree-check checkbox in each row (after the icons, before the label). Checking a folder checks everything in it; a folder with some children checked shows the indeterminate dash. Space ticks the focused row, a click on a file's name too. The inputs are real form controls - name/value submit - and every change fires tree-check with the checked values."
<div style="max-width: 20rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Files to commit" data-checkable id="commit-tree">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><input type="checkbox" class="checkbox tree-check" name="files" value="src" /><span>src</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem" aria-expanded="true">
            <details class="tree-branch" open>
              <summary class="tree-branch-trigger" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="m9 18 6-6-6-6"></path></svg
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path
                    d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                  ></path></svg
                ><input type="checkbox" class="checkbox tree-check" name="files" value="components" /><span
                  >components</span
                ></summary
              >
              <ul class="tree-group" role="group">
                <li class="tree-item" role="treeitem"
                  ><span class="tree-leaf" tabindex="0"
                    ><svg
                      aria-hidden="true"
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><input type="checkbox" class="checkbox tree-check" name="files" value="button-ts" checked /><span
                      >button.ts</span
                    ></span
                  ></li
                >
                <li class="tree-item" role="treeitem"
                  ><span class="tree-leaf" tabindex="0"
                    ><svg
                      aria-hidden="true"
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><input type="checkbox" class="checkbox tree-check" name="files" value="card-ts" /><span
                      >card.ts</span
                    ></span
                  ></li
                >
                <li class="tree-item" role="treeitem"
                  ><span class="tree-leaf" tabindex="0"
                    ><svg
                      aria-hidden="true"
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="2"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                    >
                      <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                      <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                    ><input type="checkbox" class="checkbox tree-check" name="files" value="dialog-ts" /><span
                      >dialog.ts</span
                    ></span
                  ></li
                >
              </ul>
            </details>
          </li>
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="files" value="index-ts" /><span
                >index.ts</span
              ></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="false">
      <details class="tree-branch">
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><input type="checkbox" class="checkbox tree-check" name="files" value="docs" /><span>docs</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="files" value="guide-md" /><span
                >guide.md</span
              ></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><input type="checkbox" class="checkbox tree-check" name="files" value="api-md" /><span
                >api.md</span
              ></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem"
      ><span class="tree-leaf" tabindex="0"
        ><svg
          aria-hidden="true"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
        ><input type="checkbox" class="checkbox tree-check" name="files" value="package-json" checked /><span
          >package.json</span
        ></span
      ></li
    >
  </ul>
</div>
<p class="text-sm text-muted-foreground" style="margin: 0.75rem 0 0"
  >Checked: <output id="commit-out">button.ts, package.json</output></p
>
<script>
  document.getElementById('commit-tree').addEventListener('tree-check', (e) => {
    document.getElementById('commit-out').textContent = e.detail.values.join(', ') || 'nothing';
  });
</script>
```

```html example label="Drag and drop" hint="data-sortable: drag a row onto the upper or lower edge of another to put it before or after, onto the middle of a folder to move it inside (the folder opens). Keyboard: Alt+ArrowUp / Alt+ArrowDown moves the focused row among its siblings. Every move fires tree-reorder with the item, its new parent and index."
<div style="max-width: 20rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.5rem">
  <ul class="tree" role="tree" aria-label="Playlists" data-sortable id="play-tree">
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>Morning</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Sunrise</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Coffee</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Commute</span></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="true">
      <details class="tree-branch" open>
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>Focus</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Deep work</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Lo-fi</span></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem" aria-expanded="false">
      <details class="tree-branch">
        <summary class="tree-branch-trigger" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6"></path></svg
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path
              d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
            ></path></svg
          ><span>Evening</span></summary
        >
        <ul class="tree-group" role="group">
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Dinner</span></span
            ></li
          >
          <li class="tree-item" role="treeitem"
            ><span class="tree-leaf" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
              ><span>Night walk</span></span
            ></li
          >
        </ul>
      </details>
    </li>
    <li class="tree-item" role="treeitem"
      ><span class="tree-leaf" tabindex="0"
        ><svg
          aria-hidden="true"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
          <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
        ><span>Unsorted</span></span
      ></li
    >
  </ul>
</div>
<p class="text-sm text-muted-foreground" style="margin: 0.75rem 0 0">Last move: <output id="play-out">-</output></p>
<script>
  document.getElementById('play-tree').addEventListener('tree-reorder', (e) => {
    const name = (el) =>
      el.querySelector(':scope > * span:last-child, :scope > details > summary > span:last-child')?.textContent ??
      'top';
    document.getElementById('play-out').textContent =
      name(e.detail.item) +
      ' → ' +
      (e.detail.parent.matches('.tree') ? 'top level' : name(e.detail.parent)) +
      ', position ' +
      (e.detail.index + 1);
  });
</script>
```

```html example label="Beyond files" hint="Any hierarchy fits: product categories, an org chart, a docs navigation menu. Icons are optional - the chevron is the only required glyph. Navigation leaves are links (a.tree-leaf with href); aria-selected marks the current page."
<div class="grid grid-cols-auto gap-4" style="--layout-min: 14rem">
  <div>
    <p class="demo-label">Product categories</p>
    <ul class="tree" role="tree" aria-label="Product categories" data-selectable>
      <li class="tree-item" role="treeitem" aria-expanded="true">
        <details class="tree-branch" open>
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>Electronics</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem" aria-expanded="true">
              <details class="tree-branch" open>
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><span>Audio</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"><span>Headphones</span></span></li
                  >
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"><span>Speakers</span></span></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>Cameras</span></span></li
            >
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>Laptops</span></span></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem" aria-expanded="false">
        <details class="tree-branch">
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>Home & Garden</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>Furniture</span></span></li
            >
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>Lighting</span></span></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem"
        ><span class="tree-leaf" tabindex="0"><span>Books</span></span></li
      >
    </ul>
  </div>
  <div>
    <p class="demo-label">Org chart</p>
    <ul class="tree" role="tree" aria-label="Organisation" data-variant="guides">
      <li class="tree-item" role="treeitem" aria-expanded="true">
        <details class="tree-branch" open>
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>Maria Chen · CEO</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem" aria-expanded="true">
              <details class="tree-branch" open>
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><span>Jonas Weber · CTO</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"><span>Platform team (6)</span></span></li
                  >
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"><span>Design systems (4)</span></span></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem" aria-expanded="false">
              <details class="tree-branch">
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><span>Aisha Khan · CFO</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"><span>Finance (5)</span></span></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>Tom Ruiz · Chief of Staff</span></span></li
            >
          </ul>
        </details>
      </li>
    </ul>
  </div>
  <div>
    <p class="demo-label">Navigation menu</p>
    <nav aria-label="Documentation">
      <ul class="tree" role="tree" aria-label="Documentation" data-selectable>
        <li class="tree-item" role="treeitem" aria-expanded="true">
          <details class="tree-branch" open>
            <summary class="tree-branch-trigger" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="m9 18 6-6-6-6"></path></svg
              ><span>Getting started</span></summary
            >
            <ul class="tree-group" role="group">
              <li class="tree-item" role="treeitem"
                ><a class="tree-leaf" href="#installation"><span>Installation</span></a></li
              >
              <li class="tree-item" role="treeitem" aria-selected="true"
                ><a class="tree-leaf" href="#theming"><span>Theming</span></a></li
              >
            </ul>
          </details>
        </li>
        <li class="tree-item" role="treeitem" aria-expanded="false">
          <details class="tree-branch">
            <summary class="tree-branch-trigger" tabindex="0"
              ><svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              >
                <path d="m9 18 6-6-6-6"></path></svg
              ><span>Components</span></summary
            >
            <ul class="tree-group" role="group">
              <li class="tree-item" role="treeitem"
                ><a class="tree-leaf" href="#button"><span>Button</span></a></li
              >
              <li class="tree-item" role="treeitem"
                ><a class="tree-leaf" href="#dialog"><span>Dialog</span></a></li
              >
            </ul>
          </details>
        </li>
        <li class="tree-item" role="treeitem"
          ><a class="tree-leaf" href="#changelog"><span>Changelog</span></a></li
        >
      </ul>
    </nav>
  </div>
</div>
```

```html example label="Collapsed and expanded" hint="The same tree authored two ways: every <details> closed (only the top level shows) or every <details> open with aria-expanded='true' (the whole hierarchy at once). The open attribute is the whole API; each branch's api.setState('expanded') / ('default') changes it later."
<div class="grid grid-cols-auto gap-4" style="--layout-min: 14rem">
  <div>
    <p class="demo-label">Fully collapsed</p>
    <ul class="tree" role="tree" aria-label="Collapsed project">
      <li class="tree-item" role="treeitem" aria-expanded="false">
        <details class="tree-branch">
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path
                d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
              ></path></svg
            ><span>src</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem" aria-expanded="false">
              <details class="tree-branch">
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path
                      d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                    ></path></svg
                  ><span>components</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>button.tsx</span></span
                    ></li
                  >
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>card.tsx</span></span
                    ></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem" aria-expanded="false">
              <details class="tree-branch">
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path
                      d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                    ></path></svg
                  ><span>lib</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>utils.ts</span></span
                    ></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                  <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                ><span>index.ts</span></span
              ></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem" aria-expanded="false">
        <details class="tree-branch">
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path
                d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
              ></path></svg
            ><span>tests</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                  <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                ><span>app.test.ts</span></span
              ></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem"
        ><span class="tree-leaf" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
          ><span>package.json</span></span
        ></li
      >
    </ul>
  </div>
  <div>
    <p class="demo-label">Fully expanded</p>
    <ul class="tree" role="tree" aria-label="Expanded project">
      <li class="tree-item" role="treeitem" aria-expanded="true">
        <details class="tree-branch" open>
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path
                d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
              ></path></svg
            ><span>src</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem" aria-expanded="true">
              <details class="tree-branch" open>
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path
                      d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                    ></path></svg
                  ><span>components</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>button.tsx</span></span
                    ></li
                  >
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>card.tsx</span></span
                    ></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem" aria-expanded="true">
              <details class="tree-branch" open>
                <summary class="tree-branch-trigger" tabindex="0"
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path d="m9 18 6-6-6-6"></path></svg
                  ><svg
                    aria-hidden="true"
                    xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    stroke-width="2"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path
                      d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
                    ></path></svg
                  ><span>lib</span></summary
                >
                <ul class="tree-group" role="group">
                  <li class="tree-item" role="treeitem"
                    ><span class="tree-leaf" tabindex="0"
                      ><svg
                        aria-hidden="true"
                        xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="2"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                      >
                        <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                        <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                      ><span>utils.ts</span></span
                    ></li
                  >
                </ul>
              </details>
            </li>
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                  <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                ><span>index.ts</span></span
              ></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem" aria-expanded="true">
        <details class="tree-branch" open>
          <summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><svg
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path
                d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"
              ></path></svg
            ><span>tests</span></summary
          >
          <ul class="tree-group" role="group">
            <li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"
                ><svg
                  aria-hidden="true"
                  xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  stroke-linecap="round"
                  stroke-linejoin="round"
                >
                  <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
                  <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
                ><span>app.test.ts</span></span
              ></li
            >
          </ul>
        </details>
      </li>
      <li class="tree-item" role="treeitem"
        ><span class="tree-leaf" tabindex="0"
          ><svg
            aria-hidden="true"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
            <path d="M14 2v4a2 2 0 0 0 2 2h4"></path></svg
          ><span>package.json</span></span
        ></li
      >
    </ul>
  </div>
</div>
```

```html example label="Density" hint="Set data-density on the component root to scale its internal whitespace. A whitespace policy, not a zoom: only gaps and padding scale (ratio 0.75 / 1 / 1.25), typography and fixed dimensions stay identical. comfortable matches the unsized default."
<div class="flex flex-wrap gap-4">
  <div class="flex-1 min-w-48">
    <p class="demo-label">Compact</p>
    <ul class="tree" role="tree" aria-label="Files compact" data-density="compact"
      ><li class="tree-item" role="treeitem" aria-expanded="true"
        ><details class="tree-branch" open
          ><summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              width="16"
              height="16"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>src</span></summary
          ><ul class="tree-group" role="group"
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>button.ts</span></span></li
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>card.ts</span></span></li
            ></ul
          ></details
        ></li
      ></ul
    >
  </div>
  <div class="flex-1 min-w-48">
    <p class="demo-label">Comfortable</p>
    <ul class="tree" role="tree" aria-label="Files comfortable" data-density="comfortable"
      ><li class="tree-item" role="treeitem" aria-expanded="true"
        ><details class="tree-branch" open
          ><summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              width="16"
              height="16"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>src</span></summary
          ><ul class="tree-group" role="group"
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>button.ts</span></span></li
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>card.ts</span></span></li
            ></ul
          ></details
        ></li
      ></ul
    >
  </div>
  <div class="flex-1 min-w-48">
    <p class="demo-label">Spacious</p>
    <ul class="tree" role="tree" aria-label="Files spacious" data-density="spacious"
      ><li class="tree-item" role="treeitem" aria-expanded="true"
        ><details class="tree-branch" open
          ><summary class="tree-branch-trigger" tabindex="0"
            ><svg
              aria-hidden="true"
              width="16"
              height="16"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
            >
              <path d="m9 18 6-6-6-6"></path></svg
            ><span>src</span></summary
          ><ul class="tree-group" role="group"
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>button.ts</span></span></li
            ><li class="tree-item" role="treeitem"
              ><span class="tree-leaf" tabindex="0"><span>card.ts</span></span></li
            ></ul
          ></details
        ></li
      ></ul
    >
  </div>
</div>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">Named states via the shared State API, driven per instance through the bound <code>api</code>:</p>
  <ul class="text-sm text-muted-foreground m-0 mb-3 ps-5">
    <li><code>default</code> - branch closed (a branch written <code>open</code> starts in <code>expanded</code>; <code>setState('default')</code> closes it)</li>
    <li><code>expanded</code> - branch open, children visible (per-branch API; <code>aria-expanded</code> stays in sync via the toggle event)</li>
  </ul>
  <p class="text-sm text-muted-foreground">The demo element carries <code>data-state-demo</code>; <code>bun run screenshots</code> drives it via <code>el.api.setState(name)</code> and captures <code>screenshots/\{mode\}/tree-view-\{state\}.png</code>.</p>

Machine contract - verified against <a class="link" href="../schemas/tree-view.schema.json"><code>tree-view.schema.json</code></a> by <code>bun run verify</code>:

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `expanded` | `boolean` | `true`, `false` | `false` | First branch open (native `<details open>`); `false` closes it (`default`). |
```

</StatesSection>

<ApiSection component="tree-view" />

<SourceFiles component="tree-view" section="css">
  <SourceNote for="css">Styles for the tree-view component. Uses design tokens for colors, spacing, and radius.</SourceNote>
</SourceFiles>

<SourceFiles component="tree-view" section="js">
  <SourceNote for="js">Interaction logic for the tree-view component. Uses data attributes for wiring.</SourceNote>
</SourceFiles>

</DocPage>
