Bootstrap 5 Admin Sidebar Menu with Collapsible Rail
The strongest single variant of an admin menu: a responsive admin shell with an icon sidebar that collapses to a hover- and focus-expand rail, a top bar, a highlight banner and a status table.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<div class="wdw-card overflow-hidden admin-shell" id="adminShell">
<aside class="admin-side" aria-label="Sidebar">
<div class="d-flex align-items-center gap-2 px-3 admin-brand">
<span class="wdw-icon" style="width:2.25rem;height:2.25rem"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2 2 7l10 5 10-5-10-5Z"/><path d="m2 17 10 5 10-5M2 12l10 5 10-5"/></svg></span>
<strong class="admin-label">Simple Admin</strong>
</div>
<nav class="nav flex-column gap-1 p-2" id="adminNav">
<a class="nav-link d-flex align-items-center gap-3 rounded-3 active" href="#" aria-label="Dashboard" title="Dashboard" aria-current="page"><svg viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/></svg><span class="admin-label">Dashboard</span></a>
<a class="nav-link d-flex align-items-center gap-3 rounded-3" href="#" aria-label="Customers" title="Customers"><svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8"/></svg><span class="admin-label">Customers</span></a>
<a class="nav-link d-flex align-items-center gap-3 rounded-3" href="#" aria-label="Orders" title="Orders"><svg viewBox="0 0 24 24"><path d="M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"/><path d="M3 6h18"/><path d="M16 10a4 4 0 0 1-8 0"/></svg><span class="admin-label">Orders</span><span class="badge rounded-pill text-bg-primary ms-auto admin-label">12</span></a>
<a class="nav-link d-flex align-items-center gap-3 rounded-3" href="#" aria-label="Reports" title="Reports"><svg viewBox="0 0 24 24"><path d="M3 3v18h18"/><path d="m7 15 4-4 3 3 5-6"/></svg><span class="admin-label">Reports</span></a>
<a class="nav-link d-flex align-items-center gap-3 rounded-3" href="#" aria-label="Settings" title="Settings"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1Z"/></svg><span class="admin-label">Settings</span></a>
</nav>
</aside>
<div class="admin-main">
<header class="d-flex align-items-center gap-3 px-3 px-md-4 border-bottom admin-top">
<span class="fw-bold d-sm-none">Dashboard</span>
<button class="btn btn-outline-secondary btn-sm rounded-pill px-3 d-none d-sm-inline-flex" id="adminToggle" type="button" aria-controls="adminShell" aria-pressed="false"><svg 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"><rect x="3" y="3" width="18" height="18" rx="3"/><path d="M9 3v18"/></svg><span id="adminToggleText">Collapse menu</span></button>
<span class="ms-auto small wdw-muted d-none d-sm-inline">Hover the rail to peek</span>
<img class="rounded-circle ms-auto ms-sm-0" src="https://i.pravatar.cc/72?img=12" width="36" height="36" alt="Signed in as Alex Morgan">
</header>
<div class="p-3 p-md-4">
<div class="rounded-4 p-4 mb-4 wdw-aurora">
<span class="wdw-eyebrow text-white opacity-75">Overview</span>
<h1 class="h3 fw-bold mb-1">Good morning, Alex</h1>
<p class="mb-3 text-white" style="opacity:.9">Revenue is up 8.2% this week. Three orders need your attention.</p>
<a class="btn btn-light btn-sm rounded-pill px-3" href="#">Review orders</a>
</div>
<div class="table-responsive">
<table class="table align-middle mb-0">
<thead><tr><th class="d-none d-sm-table-cell">#</th><th>Customer</th><th class="d-none d-sm-table-cell">Plan</th><th class="text-end">Status</th></tr></thead>
<tbody>
<tr><td class="d-none d-sm-table-cell">1</td><td>Mark Otto</td><td class="d-none d-sm-table-cell">Pro</td><td class="text-end"><span class="badge bg-success-subtle text-success-emphasis">Active</span></td></tr>
<tr><td class="d-none d-sm-table-cell">2</td><td>Jacob Thornton</td><td class="d-none d-sm-table-cell">Team</td><td class="text-end"><span class="badge bg-warning-subtle text-warning-emphasis">Pending</span></td></tr>
<tr><td class="d-none d-sm-table-cell">3</td><td>Larry Bird</td><td class="d-none d-sm-table-cell">Starter</td><td class="text-end"><span class="badge bg-success-subtle text-success-emphasis">Active</span></td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.admin-shell{display:flex;min-height:520px}
.admin-side{width:230px;flex:none;background:var(--bs-tertiary-bg);border-right:1px solid var(--bs-border-color-translucent);transition:width .25s ease;overflow:hidden}
.admin-brand{height:64px;white-space:nowrap}
.admin-main{flex:1;min-width:0}
.admin-top{height:64px}
.admin-side .nav-link{padding:.7rem .85rem;white-space:nowrap;font-weight:600;font-size:.925rem;text-decoration:none}
.admin-side .nav-link svg{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.admin-side .nav-link:hover{background:var(--bs-secondary-bg);color:var(--bs-emphasis-color)}
.admin-side .nav-link.active{background:var(--bs-primary-bg-subtle);color:var(--bs-primary-text-emphasis)}
.admin-side .nav-link:focus-visible{outline:2px solid var(--bs-primary);outline-offset:-2px}
.admin-label{transition:opacity .15s}
.admin-shell.is-rail .admin-side{width:72px}
.admin-shell.is-rail .admin-side:hover,.admin-shell.is-rail .admin-side:focus-within{width:230px}
.admin-shell.is-rail .admin-side:not(:hover):not(:focus-within) .admin-label{opacity:0}
@media (max-width:575.98px){
.admin-side{width:72px}
.admin-side .admin-label{display:none}
.admin-shell.is-rail .admin-side:hover,.admin-shell.is-rail .admin-side:focus-within{width:72px}
.admin-brand{justify-content:center;padding-inline:0!important}
}
(function initAdminMenu() {
var shell = document.getElementById('adminShell');
var btn = document.getElementById('adminToggle');
var nav = document.getElementById('adminNav');
if (!shell || !btn) return;
btn.addEventListener('click', function () {
var rail = shell.classList.toggle('is-rail');
btn.setAttribute('aria-pressed', rail);
var t = document.getElementById('adminToggleText');
if (t) t.textContent = rail ? 'Expand menu' : 'Collapse menu';
});
nav.addEventListener('click', function (e) {
var link = e.target.closest('.nav-link');
if (!link) return;
e.preventDefault();
nav.querySelectorAll('.nav-link').forEach(function (l) { l.classList.remove('active'); l.removeAttribute('aria-current'); });
link.classList.add('active');
link.setAttribute('aria-current', 'page');
});
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.