Snippets Navigation

Bootstrap 5 Responsive Sidebar Navigation

An app shell with a collapsible sidebar navigation that sits beside the content on desktop and slides over it with a scrim on phones.

Bootstrap 5 No jQuery Jun 2019 7.7K views

<section class="wdw-stage"><div class="container" style="max-width:1000px">
<div class="shell wdw-card overflow-hidden" id="shell">
<aside class="side offcanvas-md offcanvas-start" id="sidebar" tabindex="-1" aria-labelledby="sideBrand">
<div class="offcanvas-header px-3 pt-3 pb-2"><span class="fw-bold fs-5 d-flex align-items-center gap-2" id="sideBrand"><span class="wdw-icon" style="width:2rem;height:2rem;border-radius:.6rem"><svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M5 3h14a1 1 0 0 1 1 1v17l-8-4-8 4V4a1 1 0 0 1 1-1z"/></svg></span>Project</span>
<button type="button" class="btn-close d-md-none" data-bs-dismiss="offcanvas" data-bs-target="#sidebar" aria-label="Close menu"></button></div>
<div class="offcanvas-body d-flex flex-column p-0">
<ul class="nav nav-pills flex-column gap-1 px-2 pt-2"><li class="nav-item"><a href="#" class="nav-link d-flex align-items-center gap-3 active" aria-current="page"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1z"/></svg><span>Home</span></a></li><li class="nav-item"><a href="#" class="nav-link d-flex align-items-center gap-3"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg><span>Projects</span></a></li><li class="nav-item"><a href="#" class="nav-link d-flex align-items-center gap-3"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"/><circle cx="10" cy="7" r="4"/><path d="M21 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8"/></svg><span>Team</span></a></li><li class="nav-item"><a href="#" class="nav-link d-flex align-items-center gap-3"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg><span>Messages</span></a></li><li class="nav-item"><a href="#" class="nav-link d-flex align-items-center gap-3"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M2 12h3M19 12h3M4.9 19.1 7 17M17 7l2.1-2.1"/></svg><span>Settings</span></a></li></ul>
<div class="mt-auto p-3"><button type="button" class="btn w-100 d-flex align-items-center gap-2 p-2 rounded-4 bg-body-tertiary text-start border-0 dropdown-toggle" aria-label="Account menu"><img src="https://i.pravatar.cc/72?img=12" alt="" width="36" height="36" class="rounded-circle"><span class="lh-sm small text-truncate flex-grow-1"><strong class="d-block">Alex Morgan</strong><span class="text-body-secondary">[email protected]</span></span></button></div>
</div></aside>
<div class="main">
<header class="d-flex align-items-center gap-3 px-3 py-2 border-bottom"><button type="button" class="btn btn-icon-sm rounded-3 border-0 bg-body-tertiary text-body" id="sideToggle" aria-controls="sidebar" aria-expanded="true" aria-label="Toggle menu"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h10"/></svg></button>
<nav aria-label="Breadcrumb"><ol class="breadcrumb mb-0 small"><li class="breadcrumb-item">Workspace</li><li class="breadcrumb-item active" aria-current="page" id="crumb">Home</li></ol></nav></header>
<div class="p-3 p-md-4"><div class="row g-3"><div class="col-6 col-lg-3"><div class="wdw-card-sm p-3"><div class="small wdw-muted">Projects</div><div class="d-flex align-items-baseline justify-content-between gap-2"><div class="h4 wdw-heading mb-0">24</div><span class="badge rounded-pill text-bg-success">+12%</span></div></div></div><div class="col-6 col-lg-3"><div class="wdw-card-sm p-3"><div class="small wdw-muted">Tasks</div><div class="d-flex align-items-baseline justify-content-between gap-2"><div class="h4 wdw-heading mb-0">138</div><span class="badge rounded-pill text-bg-success">+8%</span></div></div></div><div class="col-6 col-lg-3"><div class="wdw-card-sm p-3"><div class="small wdw-muted">Members</div><div class="d-flex align-items-baseline justify-content-between gap-2"><div class="h4 wdw-heading mb-0">12</div><span class="badge rounded-pill text-bg-success">+2</span></div></div></div><div class="col-6 col-lg-3"><div class="wdw-card-sm p-3"><div class="small wdw-muted">Uptime</div><div class="d-flex align-items-baseline justify-content-between gap-2"><div class="h4 wdw-heading mb-0">99.9%</div><span class="badge rounded-pill text-bg-danger">-0.1%</span></div></div></div></div>
<div class="row g-3 mt-0 mt-md-1"><div class="col-lg-6"><div class="wdw-card-sm p-3 p-md-4 h-100"><div class="d-flex justify-content-between align-items-center mb-2"><h2 class="h6 mb-0">Tasks completed</h2><span class="small wdw-muted">Last 14 days</span></div>
<svg viewBox="0 0 300 90" class="w-100 spark" role="img" aria-label="Line chart of tasks completed, trending up" preserveAspectRatio="none"><defs><linearGradient id="spk" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="currentColor" stop-opacity=".25"/><stop offset="1" stop-color="currentColor" stop-opacity="0"/></linearGradient></defs><path d="M0 70 L25 62 L50 66 L75 50 L100 55 L125 40 L150 46 L175 30 L200 38 L225 22 L250 28 L275 12 L300 18 L300 90 L0 90Z" fill="url(#spk)"/><path d="M0 70 L25 62 L50 66 L75 50 L100 55 L125 40 L150 46 L175 30 L200 38 L225 22 L250 28 L275 12 L300 18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round" vector-effect="non-scaling-stroke"/></svg></div></div>
<div class="col-lg-6"><div class="wdw-card-sm p-3 p-md-4 h-100"><h2 class="h6 mb-2">Recent activity</h2><ul class="list-unstyled m-0"><li class="d-flex align-items-center gap-3 py-2"><img src="https://i.pravatar.cc/64?img=11" alt="" width="32" height="32" class="rounded-circle"><div class="flex-grow-1 small text-truncate">Maya closed 4 tasks</div><span class="small wdw-muted text-nowrap">2m ago</span></li><li class="d-flex align-items-center gap-3 py-2"><img src="https://i.pravatar.cc/64?img=12" alt="" width="32" height="32" class="rounded-circle"><div class="flex-grow-1 small text-truncate">New member joined</div><span class="small wdw-muted text-nowrap">1h ago</span></li><li class="d-flex align-items-center gap-3 py-2"><img src="https://i.pravatar.cc/64?img=32" alt="" width="32" height="32" class="rounded-circle"><div class="flex-grow-1 small text-truncate">Sprint 14 deployed</div><span class="small wdw-muted text-nowrap">3h ago</span></li><li class="d-flex align-items-center gap-3 py-2"><img src="https://i.pravatar.cc/64?img=5" alt="" width="32" height="32" class="rounded-circle"><div class="flex-grow-1 small text-truncate">Alex commented on Design</div><span class="small wdw-muted text-nowrap">Yesterday</span></li></ul></div></div></div></div>
</div></div></div></section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.