Component
Collapsible Sidebar
Expandable sidebar with toggle functionality and collapsible menu sections. Features smooth animations and compact mode.
- Component
- Tailwind
- HTML
- MIT
Preview
Live component
9:41 100%
devsnips.dev/library/tailwind/components/navigation/collapsible-sidebar/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Components/Navigation/collapsible-sidebar Tailwind/Components/Navigation/collapsible-sidebar <aside id="sidebar" class="fixed inset-y-0 left-0 w-64 -translate-x-full lg:translate-x-0 transition-all duration-300 ease-in-out z-40 bg-white border-r border-gray-200 flex flex-col">
<!-- Logo -->
<div class="h-16 flex items-center justify-between px-4 border-b border-gray-100">
<a href="#" class="flex items-center gap-3">
<div class="w-9 h-9 bg-gradient-to-br from-violet-500 to-purple-600 rounded-xl flex items-center justify-center">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
</div>
<span class="text-gray-900 text-lg font-bold">Nexus</span>
</a>
<button id="toggle-btn" class="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors" aria-label="Toggle sidebar">
<svg class="w-5 h-5 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 19l-7-7 7-7m8 14l-7-7 7-7"/>
</svg>
</button>
</div>
<!-- Navigation -->
<nav class="flex-1 overflow-y-auto py-4 px-3">
<div class="space-y-1">
<a href="#" class="flex items-center gap-3 px-3 py-2.5 bg-violet-50 text-violet-600 rounded-lg font-medium">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/>
</svg>
<span>Dashboard</span>
</a>
<a href="#" class="flex items-center gap-3 px-3 py-2.5 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
<span>Analytics</span>
</a>
<a href="#" class="flex items-center gap-3 px-3 py-2.5 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"/>
</svg>
<span>Customers</span>
</a>
<!-- Collapsible Section -->
<div class="pt-4">
<button id="collapse-toggle" class="flex items-center justify-between w-full px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider hover:text-gray-600">
<span>Components</span>
<svg class="w-4 h-4 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
</svg>
</button>
<div id="collapse-content" class="mt-1 space-y-1">
<a href="#" class="flex items-center gap-3 px-3 py-2 pl-10 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors">
<span>Buttons</span>
</a>
<a href="#" class="flex items-center gap-3 px-3 py-2 pl-10 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors">
<span>Cards</span>
</a>
<a href="#" class="flex items-center gap-3 px-3 py-2 pl-10 text-gray-600 hover:bg-gray-50 rounded-lg transition-colors">
<span>Forms</span>
</a>
<a href="#" class="flex items-center gap-3 px-3 py-2 pl-10 text-violet-600 bg-violet-50 rounded-lg">
<span>Navigation</span>
</a>
</div>
</div>
</div>
</nav>
<!-- User Profile -->
<div class="p-4 border-t border-gray-100">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-gradient-to-br from-violet-400 to-purple-500 rounded-full flex items-center justify-center">
<span class="text-white text-sm font-medium">JD</span>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">John Doe</p>
<p class="text-xs text-gray-500 truncate">john@example.com</p>
</div>
</div>
</div>
</aside> # Collapsible Sidebar
Collapsible sidebar navigation.
## Usage
```bash
npx devsnips add Tailwind/Components/Navigation/collapsible-sidebar
```
Copy from `code.html`.
## File Structure
`code.html` · `preview.html` · `metadata.json` · `README.md` 79 lines UTF-8 · LF · Spaces: 2
Continue browsing