Back to CSS Sidebar Navigation Responsive Dashboard Sidebar Navigation with Submenus Pure CSS
Share
HTML
<section class="sn-dsh" aria-label="Dashboard sidebar with submenus demo">
  <input type="checkbox" id="sn-dsh-d" class="toggle" aria-label="Toggle dashboard nav">
  <aside class="sidebar" aria-label="Dashboard navigation">
    <div class="brand">
      <div class="logo" aria-hidden="true">◈</div>
      <div><b>Nodal</b><small>Workspace</small></div>
    </div>
    <nav class="nav">
      <div class="cap">Overview</div>
      <a class="item active" href="#"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/></svg>Dashboard</a>

      <input type="checkbox" id="sn-dsh-s1" class="sub-toggle" checked>
      <label class="item" for="sn-dsh-s1"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M3 3v18h18"/><path d="M7 16l4-6 4 3 5-8"/></svg>Analytics<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M9 18l6-6-6-6" stroke-width="2.2"/></svg></label>
      <div class="submenu">
        <a class="dot" href="#">Traffic Sources</a>
        <a class="dot" href="#">Conversions</a>
        <a class="dot" href="#">Funnels</a>
        <a class="dot" href="#">Cohorts</a>
      </div>

      <input type="checkbox" id="sn-dsh-s2" class="sub-toggle">
      <label class="item" for="sn-dsh-s2"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><circle cx="9" cy="7" r="4"/><path d="M3 21v-2a4 4 0 014-4h4a4 4 0 014 4v2"/><path d="M16 3.13a4 4 0 010 7.75"/></svg>Audience<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M9 18l6-6-6-6" stroke-width="2.2"/></svg></label>
      <div class="submenu">
        <a class="dot" href="#">Segments</a>
        <a class="dot" href="#">Demographics</a>
        <a class="dot" href="#">Retention</a>
      </div>

      <div class="cap">Manage</div>
      <input type="checkbox" id="sn-dsh-s3" class="sub-toggle">
      <label class="item" for="sn-dsh-s3"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M20 7h-9M14 17H5M17 17a3 3 0 100-6 3 3 0 000 6zM7 13a3 3 0 100-6 3 3 0 000 6z"/></svg>Settings<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M9 18l6-6-6-6" stroke-width="2.2"/></svg></label>
      <div class="submenu">
        <a class="dot" href="#">General</a>
        <a class="dot" href="#">Billing</a>
        <a class="dot" href="#">API Keys</a>
      </div>
      <a class="item" href="#"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg>Support</a>
    </nav>
    <div class="pro">
      <b>Upgrade to Pro</b>
      <p>Unlock unlimited dashboards and real-time exports.</p>
      <button type="button">Upgrade now</button>
    </div>
  </aside>
  <label for="sn-dsh-d" class="overlay" aria-hidden="true"></label>

  <div class="mainpane">
    <div class="top">
      <label for="sn-dsh-d" class="mbtn" aria-label="Open navigation">
        <svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16" stroke-width="2" stroke-linecap="round"/></svg>
      </label>
      <h1>Dashboard</h1>
    </div>
    <div class="body">
      <div class="card"><div class="k">Active Users</div><div class="v">24.7k</div><div class="d">▲ 12.4%</div></div>
      <div class="card"><div class="k">Revenue</div><div class="v">$89.2k</div><div class="d">▲ 8.1%</div></div>
      <div class="card"><div class="k">Conversion</div><div class="v">3.42%</div><div class="d">▲ 0.6%</div></div>
      <div class="card"><div class="k">Sessions</div><div class="v">112k</div><div class="d">▲ 19%</div></div>
    </div>
  </div>
</section>
CSS
/* ─── 04 Dashboard Sidebar with Submenus — SaaS dark ──────── */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

.sn-dsh {
  --sn-dsh-bg: #0a0e14;
  --sn-dsh-panel: #10151f;
  --sn-dsh-panel-2: #161d2b;
  --sn-dsh-line: #1e2737;
  --sn-dsh-txt: #dfe6f0;
  --sn-dsh-muted: #6b7689;
  --sn-dsh-brand: #5b8cff;
  --sn-dsh-brand-2: #8b5cf6;
  --sn-dsh-good: #34d399;

  position: relative;
  width: 100%;
  height: 600px;
  font-family: 'Manrope', sans-serif;
  background: var(--sn-dsh-bg);
  color: var(--sn-dsh-txt);
  display: flex;
  overflow: hidden;
  box-sizing: border-box;
}
.sn-dsh *, .sn-dsh *::before, .sn-dsh *::after { box-sizing: border-box; margin: 0; padding: 0; }

.sn-dsh .toggle { display: none; }
.sn-dsh .overlay { display: none; }

.sn-dsh .sidebar {
  width: 268px; background: var(--sn-dsh-panel); border-right: 1px solid var(--sn-dsh-line);
  height: 100%; display: flex; flex-direction: column; z-index: 30; flex-shrink: 0;
}
.sn-dsh .brand { display: flex; align-items: center; gap: .7rem; padding: 1.5rem 1.4rem; }
.sn-dsh .logo { width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--sn-dsh-brand), var(--sn-dsh-brand-2));
  display: grid; place-items: center; font-weight: 800; color: #fff; }
.sn-dsh .brand b { font-size: 1.15rem; letter-spacing: -.02em; }
.sn-dsh .brand small { display: block; color: var(--sn-dsh-muted); font-size: .7rem; font-weight: 600; }

.sn-dsh .nav { padding: .5rem .8rem 1rem; flex: 1; overflow-y: auto; }
.sn-dsh .cap { font-size: .66rem; text-transform: uppercase; letter-spacing: .13em;
  color: var(--sn-dsh-muted); font-weight: 700; padding: 1rem .9rem .4rem; }

.sn-dsh .item {
  display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem;
  border-radius: 10px; color: var(--sn-dsh-txt); text-decoration: none; font-size: .9rem;
  font-weight: 500; cursor: pointer; transition: .18s;
}
.sn-dsh .item svg { width: 19px; height: 19px; stroke-width: 1.8; flex-shrink: 0; color: var(--sn-dsh-muted); }
.sn-dsh .item:hover { background: var(--sn-dsh-panel-2); }
.sn-dsh .item:hover svg { color: var(--sn-dsh-txt); }
.sn-dsh .item.active { background: linear-gradient(90deg, rgba(91,140,255,.16), rgba(139,92,246,.1)); color: #fff; }
.sn-dsh .item.active svg { color: var(--sn-dsh-brand); }
.sn-dsh .chev { margin-left: auto; width: 15px !important; height: 15px !important; transition: transform .25s; }

.sn-dsh .sub-toggle { display: none; }
.sn-dsh .submenu { max-height: 0; overflow: hidden; transition: max-height .3s ease;
  margin-left: 1.5rem; border-left: 1.5px solid var(--sn-dsh-line); padding-left: .4rem; }
.sn-dsh .submenu a { display: block; padding: .5rem .8rem; color: var(--sn-dsh-muted); text-decoration: none;
  font-size: .85rem; border-radius: 8px; transition: .18s; }
.sn-dsh .submenu a:hover { color: var(--sn-dsh-txt); background: var(--sn-dsh-panel-2); }
.sn-dsh .submenu a.dot::before { content: ""; display: inline-block; width: 5px; height: 5px;
  border-radius: 50%; background: var(--sn-dsh-muted); margin-right: .6rem; vertical-align: middle; }
.sn-dsh .sub-toggle:checked + .item .chev { transform: rotate(90deg); }
.sn-dsh .sub-toggle:checked + .item { background: var(--sn-dsh-panel-2); }
.sn-dsh .sub-toggle:checked + .item + .submenu { max-height: 240px; }

.sn-dsh .pro { margin: 1rem .8rem; padding: 1.2rem; border-radius: 14px;
  background: linear-gradient(135deg, rgba(91,140,255,.16), rgba(139,92,246,.16));
  border: 1px solid rgba(91,140,255,.25); }
.sn-dsh .pro b { font-size: .92rem; }
.sn-dsh .pro p { color: var(--sn-dsh-muted); font-size: .76rem; margin: .3rem 0 .8rem; }
.sn-dsh .pro button { width: 100%; padding: .55rem; border: none; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--sn-dsh-brand), var(--sn-dsh-brand-2)); color: #fff; font-weight: 700; font-size: .82rem; font-family: inherit; }

.sn-dsh .mainpane { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.sn-dsh .top { display: flex; align-items: center; gap: 1rem; padding: 1.3rem 2rem; border-bottom: 1px solid var(--sn-dsh-line); }
.sn-dsh .mbtn { display: none; background: none; border: 1px solid var(--sn-dsh-line); border-radius: 8px; padding: .4rem; cursor: pointer; color: var(--sn-dsh-txt); }
.sn-dsh .mbtn svg { width: 20px; height: 20px; stroke: currentColor; display: block; }
.sn-dsh .top h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.sn-dsh .body { padding: 2rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.2rem; }
.sn-dsh .card { background: var(--sn-dsh-panel); border: 1px solid var(--sn-dsh-line); border-radius: 16px; padding: 1.4rem; }
.sn-dsh .card .k { color: var(--sn-dsh-muted); font-size: .8rem; font-weight: 600; }
.sn-dsh .card .v { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin: .4rem 0; }
.sn-dsh .card .d { color: var(--sn-dsh-good); font-size: .8rem; font-weight: 700; }

@media (max-width: 880px) {
  .sn-dsh .sidebar { position: absolute; transform: translateX(-100%); transition: transform .35s; box-shadow: 8px 0 40px rgba(0,0,0,.5); }
  .sn-dsh .toggle:checked ~ .sidebar { transform: translateX(0); }
  .sn-dsh .toggle:checked ~ .overlay { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
  .sn-dsh .mbtn { display: grid; place-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .sn-dsh .submenu, .sn-dsh .chev, .sn-dsh .sidebar { transition: none; }
}