Collapsible File Tree
A recursive, data-driven tree of folders and files with expand/collapse toggles.
3 個のフレームワーク初級
A file tree that mirrors the selected file as a wrapping breadcrumb path above it.
<!-- The breadcrumb reflects the selected file. It wraps and truncates rather
than scrolling the page, and aria-live announces the change on selection. -->
<nav class="w-full max-w-sm rounded-xl border border-gray-200 bg-white text-sm text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300">
<div class="flex flex-wrap items-center gap-x-1 gap-y-0.5 border-b border-gray-200 px-3 py-2 text-xs dark:border-gray-800" aria-live="polite">
<span class="truncate text-gray-500">src</span>
<span class="text-gray-300 dark:text-gray-600" aria-hidden="true">/</span>
<span class="truncate font-medium text-gray-900 dark:text-gray-100">index.ts</span>
</div>
<ul role="tree" aria-label="Project files" class="space-y-0.5 p-2">
<li role="treeitem" aria-expanded="true">
<button type="button" class="flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 text-left hover:bg-gray-100 dark:hover:bg-gray-900">
<svg viewBox="0 0 16 16" fill="currentColor" class="h-3.5 w-3.5 shrink-0 rotate-90 text-gray-400" aria-hidden="true"><path d="M6 4l4 4-4 4z"/></svg>
<svg viewBox="0 0 16 16" fill="currentColor" class="h-4 w-4 shrink-0 text-blue-500" aria-hidden="true"><path d="M1.5 4A1.5 1.5 0 0 1 3 2.5h3L7.5 4H13A1.5 1.5 0 0 1 14.5 5.5v6A1.5 1.5 0 0 1 13 13H3a1.5 1.5 0 0 1-1.5-1.5z"/></svg>
<span class="truncate font-medium text-gray-900 dark:text-gray-100">src</span>
</button>
<ul role="group" class="ml-3 space-y-0.5 border-l border-gray-200 pl-2 sm:ml-4 dark:border-gray-800">
<li role="treeitem" aria-selected="true"><button type="button" class="flex w-full min-w-0 items-center gap-1.5 rounded-md bg-blue-50 px-2 py-1.5 text-left text-blue-700 dark:bg-blue-500/15 dark:text-blue-300"><span class="w-3.5 shrink-0"></span><svg viewBox="0 0 16 16" fill="currentColor" class="h-4 w-4 shrink-0 text-gray-400" aria-hidden="true"><path d="M4 1.5h4.6L13 5.9V14a.5.5 0 0 1-.5.5h-8A.5.5 0 0 1 4 14V2a.5.5 0 0 1 .5-.5z"/></svg><span class="truncate">index.ts</span></button></li>
</ul>
</li>
</ul>
</nav>| Prop | 型 | デフォルト | 説明 |
|---|---|---|---|
nodes必須 | TreeNode[] | - | Nodes |
label | string | 'Project files' | 読み込み中に読み上げられるアクセシブルなラベル。 |
Selecting a file lifts its full path into a breadcrumb that wraps and truncates rather than scrolling the page, and announces the change via `aria-live`. The selected row is highlighted with `aria-selected`; drive the state upward if you want the breadcrumb to control other panels.