Collapsible File Tree
A recursive, data-driven tree of folders and files with expand/collapse toggles.
3 फ्रेमवर्कशुरुआती
A multi-select file tree where a folder reflects and toggles all of its files.
<!-- A folder's checkbox is DERIVED from its files, never stored: all leaves
checked => checked, some => indeterminate. Indeterminate has no HTML
attribute; it is set on the DOM node in JS, so this static snapshot shows
the checked and unchecked states only. -->
<nav class="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-2 text-sm text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300">
<ul role="tree" aria-label="Select files" aria-multiselectable="true" class="space-y-0.5">
<li role="treeitem" aria-expanded="true" aria-checked="false">
<div class="flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-900">
<input type="checkbox" aria-label="assets" class="h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 dark:border-gray-700 dark:bg-gray-900" />
<button type="button" class="flex min-w-0 flex-1 items-center gap-1.5 text-left">
<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">assets</span>
</button>
</div>
<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-checked="false"><div class="flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-900"><input type="checkbox" aria-label="logo.svg" class="h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 dark:border-gray-700 dark:bg-gray-900" /><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">logo.svg</span></div></li>
</ul>
</li>
</ul>
</nav>| Prop | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
nodesआवश्यक | TreeNode[] | - | Nodes |
label | string | 'Select files' | लोड होते समय पढ़ा जाने वाला एक्सेसिबल लेबल। |
A folder checkbox is derived, never stored: it reads checked when every leaf under it is selected and indeterminate when only some are, and toggling it flips them all. Because indeterminate has no HTML attribute, it is set on the DOM node through a ref - the one bit of imperative code the pattern needs.