Snippets Sidebar

Bootstrap 5 Responsive Sidebar with Dropdown Menus

A responsive admin sidebar with a profile card, collapsible submenus, badges and a bottom toolbar for notifications, messages, settings and logout. On phones it becomes a slide-in drawer opened from a menu button.

Bootstrap 5 Bootstrap 6 No jQuery Mar 2020 3.8K views

<section class="wdw-stage p-0 align-items-stretch">
  <div class="wdw-shell d-flex w-100">
    <div class="offcanvas-lg offcanvas-start wdw-side d-flex flex-column" tabindex="-1" id="wdwSide" aria-labelledby="wdwSideTitle">
      <div class="d-flex align-items-center justify-content-between px-4 pt-4 pb-3">
        <a href="#" class="d-flex align-items-center gap-2 text-decoration-none" id="wdwSideTitle">
          <span class="wdw-icon" style="width:2.25rem;height:2.25rem" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2 4 14h7l-1 8 9-12h-7l1-8Z"/></svg></span>
          <span class="fw-bold fs-5 text-body-emphasis">Pro Sidebar</span>
        </a>
        <button type="button" class="btn-close d-lg-none" data-bs-dismiss="offcanvas" data-bs-target="#wdwSide" aria-label="Close menu"></button>
      </div>
      <div class="mx-3 mb-3 p-3 rounded-4 bg-primary-subtle border border-primary-subtle d-flex align-items-center gap-3">
        <img class="rounded-circle" width="44" height="44" src="https://i.pravatar.cc/88?img=32" alt="Profile photo of John Smith">
        <div class="lh-sm min-w-0">
          <strong class="d-block text-body-emphasis">John Smith</strong>
          <small class="wdw-muted d-flex align-items-center gap-1"><span class="wdw-dotlive"></span>Administrator</small>
        </div>
      </div>
      <nav class="px-3 flex-grow-1 overflow-auto" aria-label="Main">
        <small class="wdw-eyebrow px-2 mb-2">General</small>
        <ul class="list-unstyled d-grid gap-1 mb-0"><li><a class="wdw-nav" href="#"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 11 9-8 9 8"/><path d="M5 10v10h14V10"/></svg><span>Overview</span></a></li><li><button class="wdw-nav parent-active" type="button" data-bs-toggle="collapse" data-bs-target="#navShop" aria-expanded="true" aria-controls="navShop"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="20" r="1.5"/><circle cx="18" cy="20" r="1.5"/><path d="M2 3h3l2.5 12h11l2-8H6"/></svg><span>E-commerce</span><svg class="wdw-chev ms-auto" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></button><div class="collapse show" id="navShop"><ul class="list-unstyled mb-1 ms-4 ps-3 border-start"><li><a class="wdw-sub" href="#">Products</a></li><li><a class="wdw-sub active" href="#" aria-current="page">Orders</a></li><li><a class="wdw-sub" href="#">Customers</a></li></ul></div></li><li><button class="wdw-nav" type="button" data-bs-toggle="collapse" data-bs-target="#navStats" aria-expanded="false" aria-controls="navStats"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg><span>Analytics</span><span class="badge rounded-pill text-bg-primary ms-2">New</span><svg class="wdw-chev ms-auto" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></button><div class="collapse" id="navStats"><ul class="list-unstyled mb-1 ms-4 ps-3 border-start"><li><a class="wdw-sub" href="#">Traffic</a></li><li><a class="wdw-sub" href="#">Revenue</a></li><li><a class="wdw-sub" href="#">Reports</a></li></ul></div></li><li><button class="wdw-nav" type="button" data-bs-toggle="collapse" data-bs-target="#navGeo" aria-expanded="false" aria-controls="navGeo"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18"/></svg><span>Maps</span><svg class="wdw-chev ms-auto" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></button><div class="collapse" id="navGeo"><ul class="list-unstyled mb-1 ms-4 ps-3 border-start"><li><a class="wdw-sub" href="#">Google maps</a></li><li><a class="wdw-sub" href="#">Open street map</a></li></ul></div></li><li><a class="wdw-nav" href="#"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Z"/><path d="M14 3v5h5"/></svg><span>Documents</span></a></li></ul>
      </nav>
      <div class="d-flex justify-content-around border-top p-2 mt-2">
        <button type="button" class="wdw-tool position-relative" aria-label="Notifications, 3 new"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10 21h4"/></svg><span class="badge rounded-pill text-bg-danger wdw-pip">3</span></button>
        <button type="button" class="wdw-tool position-relative" aria-label="Messages, 7 new"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg><span class="badge rounded-pill text-bg-danger wdw-pip">7</span></button>
        <button type="button" class="wdw-tool" aria-label="Settings"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2"/></svg></button>
        <button type="button" class="wdw-tool" aria-label="Log out"><svg class="wdw-ni" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5M21 12H9"/></svg></button>
      </div>
    </div>
    <main class="flex-grow-1 p-4 p-lg-5 min-w-0">
      <div class="d-flex align-items-center gap-3 mb-4">
        <button class="btn btn-outline-primary d-lg-none px-3" type="button" data-bs-toggle="offcanvas" data-bs-target="#wdwSide" aria-controls="wdwSide">
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg><span class="visually-hidden">Open menu</span>
        </button>
        <div>
          <span class="wdw-eyebrow">E-commerce</span>
          <h1 class="wdw-heading h2 mb-0">Orders</h1>
        </div>
      </div>
      <div class="row g-3 g-lg-4 mb-3 mb-lg-4">
        <div class="col-12 col-sm-4"><div class="wdw-card-sm p-4"><small class="wdw-muted">Revenue</small><div class="h3 fw-bold text-body-emphasis mb-1">$48,260</div><small class="text-success fw-semibold">+12.4% this month</small></div></div>
        <div class="col-12 col-sm-4"><div class="wdw-card-sm p-4"><small class="wdw-muted">Orders</small><div class="h3 fw-bold text-body-emphasis mb-1">1,284</div><small class="text-success fw-semibold">+4.1% this month</small></div></div>
        <div class="col-12 col-sm-4"><div class="wdw-card-sm p-4"><small class="wdw-muted">Refunds</small><div class="h3 fw-bold text-body-emphasis mb-1">23</div><small class="text-danger fw-semibold">+2 this week</small></div></div>
      </div>
      <div class="row g-3 g-lg-4">
        <div class="col-12 col-xl-7">
          <section class="wdw-card-sm p-4 h-100" aria-labelledby="wdwChartTitle">
            <div class="d-flex justify-content-between align-items-start mb-3">
              <div><h2 class="h6 fw-bold text-body-emphasis mb-0" id="wdwChartTitle">Orders per day</h2><small class="wdw-muted">Last 14 days</small></div>
              <span class="badge rounded-pill text-bg-primary">+8%</span>
            </div>
            <svg class="wdw-chart text-primary w-100" viewBox="0 0 280 100" preserveAspectRatio="none" role="img" aria-label="Line chart of daily orders, rising from 40 to 95 over 14 days">
              <path d="M0 80 L20 70 L40 74 L60 55 L80 60 L100 48 L120 52 L140 38 L160 44 L180 30 L200 36 L220 22 L240 28 L260 14 L280 8 L280 100 L0 100 Z" fill="currentColor" opacity=".12"/>
              <path d="M0 80 L20 70 L40 74 L60 55 L80 60 L100 48 L120 52 L140 38 L160 44 L180 30 L200 36 L220 22 L240 28 L260 14 L280 8" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round" vector-effect="non-scaling-stroke"/>
            </svg>
            <div class="d-flex justify-content-between small wdw-muted mt-2"><span>Oct 1</span><span>Oct 7</span><span>Oct 14</span></div>
          </section>
        </div>
        <div class="col-12 col-xl-5">
          <section class="wdw-card-sm p-4 h-100" aria-labelledby="wdwRecentTitle">
            <h2 class="h6 fw-bold text-body-emphasis mb-2" id="wdwRecentTitle">Recent orders</h2>
            <ul class="list-group list-group-flush">
              <li class="list-group-item bg-transparent px-0 d-flex align-items-center justify-content-between gap-2"><span class="lh-sm"><strong class="d-block text-body-emphasis">#10482 · Maria Lopez</strong><small class="wdw-muted">2 minutes ago</small></span><span class="d-flex align-items-center gap-2"><span class="badge rounded-pill text-success-emphasis bg-success-subtle">Paid</span><span class="fw-semibold">$128</span></span></li>
              <li class="list-group-item bg-transparent px-0 d-flex align-items-center justify-content-between gap-2"><span class="lh-sm"><strong class="d-block text-body-emphasis">#10481 · Ken Aoki</strong><small class="wdw-muted">18 minutes ago</small></span><span class="d-flex align-items-center gap-2"><span class="badge rounded-pill text-warning-emphasis bg-warning-subtle">Pending</span><span class="fw-semibold">$64</span></span></li>
              <li class="list-group-item bg-transparent px-0 d-flex align-items-center justify-content-between gap-2"><span class="lh-sm"><strong class="d-block text-body-emphasis">#10480 · Sara Nilsen</strong><small class="wdw-muted">1 hour ago</small></span><span class="d-flex align-items-center gap-2"><span class="badge rounded-pill text-success-emphasis bg-success-subtle">Paid</span><span class="fw-semibold">$342</span></span></li>
              <li class="list-group-item bg-transparent px-0 d-flex align-items-center justify-content-between gap-2"><span class="lh-sm"><strong class="d-block text-body-emphasis">#10479 · Omar Haddad</strong><small class="wdw-muted">3 hours ago</small></span><span class="d-flex align-items-center gap-2"><span class="badge rounded-pill text-danger-emphasis bg-danger-subtle">Refunded</span><span class="fw-semibold">$89</span></span></li>
            </ul>
          </section>
        </div>
      </div>
    </main>
  </div>
</section>

Built on Bootstrap 6.0.0-alpha.1 (ES modules, no jQuery). Load Bootstrap through an import map and run the JavaScript as type="module" — the downloaded file is already set up that way. Alpha releases can still change class names.

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.