Snippets Menu

Bootstrap 5 Sidebar Toggle Menu

A dashboard shell with a profile card and icon navigation in a sidebar that slides open and closed from an animated menu button, overlaying the page on phones.

Bootstrap 5 No jQuery Mar 2020 3.3K views

<section class="wdw-stage">
  <div class="container" style="max-width:1080px">
    <div class="wdw-shell wdw-card" id="wdwShell">
      <aside class="wdw-side offcanvas-md offcanvas-start" id="wdwSide" tabindex="-1" aria-labelledby="wdwSideTitle">
        <div class="offcanvas-header d-md-none pb-0">
          <h2 class="offcanvas-title h6 fw-bold" id="wdwSideTitle">Menu</h2>
          <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#wdwSide" aria-label="Close menu"></button>
        </div>
        <div class="offcanvas-body d-flex flex-column p-3">
          <div class="d-flex align-items-center gap-3 p-3 mb-3 rounded-4 bg-body-tertiary">
            <img src="https://i.pravatar.cc/96?img=47" width="48" height="48" class="rounded-circle flex-none" alt="Jelena Jovanovic">
            <div class="flex-grow-1 overflow-hidden">
              <p class="fw-bold mb-0 text-body-emphasis text-truncate">Jelena Jovanovic</p>
              <p class="small wdw-muted mb-0">Web developer</p>
            </div>
          </div>
          <nav aria-label="Sidebar">
            <p class="wdw-eyebrow px-2 mb-1 text-body-secondary">Main</p>
            <ul class="list-unstyled d-grid gap-1 mb-3">
          <li><a href="#" class="wdw-side-link is-active" aria-current="page"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5V21h-6v-6H9v6H3z"/></svg><span>Overview</span></a></li>
          <li><a href="#" class="wdw-side-link"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg><span>Analytics</span></a></li>
          <li><a href="#" class="wdw-side-link"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg><span>Projects</span></a></li>
            </ul>
            <p class="wdw-eyebrow px-2 mb-1 text-body-secondary">Workspace</p>
            <ul class="list-unstyled d-grid gap-1 mb-0">
          <li><a href="#" class="wdw-side-link"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg><span>Messages</span><span class="badge rounded-pill text-bg-primary ms-auto">4</span></a></li>
          <li><a href="#" class="wdw-side-link"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5h18v16H3zM3 10h18M8 3v4M16 3v4"/></svg><span>Calendar</span></a></li>
          <li><a href="#" class="wdw-side-link"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9 7 7M17 17l2.1 2.1M4.9 19.1 7 17M17 7l2.1-2.1"/></svg><span>Settings</span></a></li>
            </ul>
          </nav>
          <div class="mt-auto pt-3">
            <div class="wdw-aurora rounded-4 p-3 mb-3">
              <p class="fw-bold mb-1">Go Pro</p>
              <p class="small text-white-50 mb-2">Unlock unlimited projects and team seats.</p>
              <button type="button" class="btn btn-light btn-sm rounded-pill px-3">Upgrade</button>
            </div>
            <div class="d-flex gap-2 px-1">
              <a href="#" class="wdw-social" aria-label="Instagram"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="5"/><circle cx="12" cy="12" r="4"/></svg></a>
              <a href="#" class="wdw-social" aria-label="YouTube"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="5.5" width="19" height="13" rx="4"/><path d="m10 9 5 3-5 3z"/></svg></a>
              <a href="#" class="wdw-social" aria-label="LinkedIn"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" aria-hidden="true"><path d="M6 10v8M6 6.5v.01M11 18v-8M11 13a3 3 0 0 1 6 0v5"/></svg></a>
            </div>
          </div>
        </div>
      </aside>
      <div class="wdw-main">
        <header class="wdw-top d-flex align-items-center gap-3 px-3 px-md-4">
          <button type="button" class="wdw-burger" id="wdwBurger" aria-label="Close sidebar" aria-expanded="true" aria-controls="wdwSide">
            <span></span><span></span><span></span>
          </button>
          <span class="fw-bold text-body-emphasis">Dashboard</span>
          <span class="ms-auto badge rounded-pill bg-primary-subtle text-primary-emphasis">Live</span>
        </header>
        <div class="p-3 p-md-4">
          <p class="wdw-eyebrow mb-1">Overview</p>
          <h2 class="wdw-heading h3 mb-3">Good morning, Jelena</h2>
          <div class="row g-3 mb-3">
            <div class="col-6"><div class="wdw-card-sm p-3 h-100"><p class="small wdw-muted mb-1">Visitors</p><p class="h4 fw-bold text-body-emphasis mb-1">24.8k</p><span class="badge text-success-emphasis rounded-pill bg-success-subtle">+12%</span></div></div>
            <div class="col-6"><div class="wdw-card-sm p-3 h-100"><p class="small wdw-muted mb-1">Revenue</p><p class="h4 fw-bold text-body-emphasis mb-1">$9.4k</p><span class="badge text-success-emphasis rounded-pill bg-success-subtle">+21%</span></div></div>
          </div>
          <div class="wdw-card-sm p-3 p-md-4">
            <div class="d-flex justify-content-between align-items-center mb-3"><span class="fw-semibold text-body-emphasis">Weekly traffic</span><span class="small wdw-muted">Last 7 days</span></div>
            <div class="wdw-bars" aria-hidden="true"><span style="--h:45%"></span><span style="--h:62%"></span><span style="--h:38%"></span><span style="--h:80%"></span><span style="--h:56%"></span><span class="is-peak" style="--h:92%"></span><span style="--h:70%"></span></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.

Free to use in personal and commercial projects under the MIT license.