Collapsible Tree View
A nested file tree with expandable and collapsible folders.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:300px"><div class="card-body small" id="tvWrap">
<div><button class="btn btn-sm btn-link text-decoration-none p-0 text-dark" data-tv>📁 src <span>▸</span></button><div class="ms-3" style="display:none"><div>📄 index.js</div><div>📄 app.js</div><div><button class="btn btn-sm btn-link text-decoration-none p-0 text-dark" data-tv>📁 utils <span>▸</span></button><div class="ms-3" style="display:none"><div>📄 helpers.js</div></div></div></div></div>
<div class="mt-1"><button class="btn btn-sm btn-link text-decoration-none p-0 text-dark" data-tv>📁 public <span>▸</span></button><div class="ms-3" style="display:none"><div>📄 index.html</div></div></div>
</div></div>document.querySelectorAll('#tvWrap [data-tv]').forEach(function(b){b.onclick=function(e){e.stopPropagation();var panel=b.nextElementSibling,open=panel.style.display==='none';panel.style.display=open?'block':'none';b.querySelector('span').textContent=open?'▾':'▸'}});Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.