Bootstrap 5 Admin Panel Layout with Charts and KPI Cards
An admin panel with a top bar, side navigation, a revenue line chart with a date-range switch and three KPI cards with sparklines.
<section class="wdw-stage"><div class="container" style="max-width:1120px">
<div class="admin wdw-card overflow-hidden">
<header class="d-flex align-items-center gap-3 px-3 px-md-4 py-3 admin-top text-white"><span class="d-flex align-items-center gap-2 fw-bold fs-5"><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" class="flex-shrink-0"><path d="M12 4l9 16H3z"/></svg>Backend</span><span class="small opacity-75 ms-md-4 d-none d-sm-inline">Overview</span><img src="https://i.pravatar.cc/64?img=32" width="36" height="36" class="rounded-circle ms-auto" alt="Signed in as Priya N."></header>
<div class="d-flex flex-column flex-md-row">
<nav class="admin-side p-2 p-md-3 d-flex flex-md-column gap-1 overflow-auto" aria-label="Admin"><div class="nav nav-pills flex-md-column flex-nowrap gap-1 w-100" id="adminNav"><a class="nav-link text-nowrap d-flex align-items-center gap-2 active" href="#" 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" class="flex-shrink-0"><circle cx="12" cy="12" r="9"/><path d="M15.5 8.5l-2 5-5 2 2-5z"/></svg>Dashboard</a><a class="nav-link text-nowrap d-flex align-items-center gap-2" href="#"><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" class="flex-shrink-0"><rect x="2.5" y="5" width="19" height="14" rx="2.5"/><path d="M2.5 10h19"/></svg>Bills & Payments</a><a class="nav-link text-nowrap d-flex align-items-center gap-2" href="#"><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" class="flex-shrink-0"><circle cx="9" cy="8" r="3.5"/><path d="M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M18 14.5a6.5 6.5 0 0 1 3.5 5.5"/></svg>Customers</a><a class="nav-link text-nowrap d-flex align-items-center gap-2" href="#"><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" class="flex-shrink-0"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5M12 16h.01"/></svg>Server Logs</a></div></nav>
<main class="flex-grow-1 wdw-min0 p-3 p-md-4 bg-body-tertiary d-flex flex-column gap-3">
<div class="wdw-card-sm p-3 p-md-4">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2"><div><h2 class="h6 mb-0 text-body-emphasis">Revenue</h2><p class="small wdw-muted mb-0">Daily income, USD</p></div>
<div class="btn-group" role="group" aria-label="Date range" id="rangeGroup"><input type="radio" class="btn-check" name="range" id="r14" value="14" autocomplete="off"><label class="btn btn-outline-primary btn-sm rounded-start-pill px-3" for="r14">14D</label><input type="radio" class="btn-check" name="range" id="r30" value="30" autocomplete="off" checked><label class="btn btn-outline-primary btn-sm px-3" for="r30">30D</label><input type="radio" class="btn-check" name="range" id="r60" value="60" autocomplete="off"><label class="btn btn-outline-primary btn-sm rounded-end-pill px-3" for="r60">60D</label></div></div>
<div id="bigChart" class="chart-big" role="img" aria-label="Line chart of daily revenue"></div></div>
<div class="row g-3">
<div class="col-12 col-sm-4"><div class="wdw-card-sm p-3 h-100"><div class="small wdw-muted">Sales</div><div class="d-flex align-items-baseline gap-2"><span class="h4 wdw-heading mb-0">$424,632</span><span class="small fw-semibold text-success">+12.4%</span></div><div class="spark mt-2" data-spark="Sales"></div></div></div>
<div class="col-12 col-sm-4"><div class="wdw-card-sm p-3 h-100"><div class="small wdw-muted">Expenses</div><div class="d-flex align-items-baseline gap-2"><span class="h4 wdw-heading mb-0">$235,312</span><span class="small fw-semibold text-danger">+3.1%</span></div><div class="spark mt-2" data-spark="Expenses"></div></div></div>
<div class="col-12 col-sm-4"><div class="wdw-card-sm p-3 h-100"><div class="small wdw-muted">Profits</div><div class="d-flex align-items-baseline gap-2"><span class="h4 wdw-heading mb-0">$135,965</span><span class="small fw-semibold text-success">+18.9%</span></div><div class="spark mt-2" data-spark="Profits"></div></div></div>
</div></main></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-top { background: #15172a; }
.admin-side { width: 100%; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }
.admin-side .nav-link { border-radius: .75rem; min-height: 44px; }
.admin-side .nav-link:not(.active):hover { background: var(--bs-secondary-bg); }
.wdw-min0 { min-width: 0; }
.chart-big { height: 260px; }
.spark { height: 56px; }
.chart-big svg, .spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-big .grid { stroke: var(--bs-border-color); stroke-width: 1; }
.chart-big text { fill: var(--bs-secondary-color); font-size: 11px; font-family: var(--wdw-font); }
.chart-line { fill: none; stroke: var(--bs-primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: var(--bs-primary); opacity: .14; }
.chart-dot { fill: var(--bs-body-bg); stroke: var(--bs-primary); stroke-width: 2.5; }
.chart-tip { position: absolute; pointer-events: none; transform: translate(-50%, -110%); font-size: .75rem; font-weight: 600; padding: .25rem .6rem; border-radius: .5rem; background: var(--bs-emphasis-color); color: var(--bs-body-bg); white-space: nowrap; }
@media (min-width: 768px) { .admin-side { width: 220px; flex: none; border-bottom: 0; border-right: 1px solid var(--bs-border-color); } }
function smoothPath(pts) {
let d = 'M' + pts[0][0] + ',' + pts[0][1];
for (let i = 0; i < pts.length - 1; i++) {
const p0 = pts[i - 1] || pts[i], p1 = pts[i], p2 = pts[i + 1], p3 = pts[i + 2] || p2;
const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
d += 'C' + c1 + ' ' + c2 + ' ' + p2;
}
return d;
}
function seeded(n, seed) {
let s = seed;
const out = [];
for (let i = 0; i < n; i++) {
s = (s * 9301 + 49297) % 233280;
out.push(50 + 28 * Math.sin(i / 3.2) + (s / 233280) * 26 + i * 0.5);
}
return out;
}
function initBigChart() {
const host = document.getElementById('bigChart');
const group = document.getElementById('rangeGroup');
if (!host || !group) return;
host.style.position = 'relative';
const H = 260, pl = 34, pb = 24, pt = 10;
let W = 760, cur = 30;
const draw = (n) => {
cur = n; W = host.clientWidth || 760;
const data = seeded(n, 7), max = 120, min = 40;
const x = (i) => pl + (i / (n - 1)) * (W - pl - 8);
const y = (v) => pt + (1 - (v - min) / (max - min)) * (H - pt - pb);
const pts = data.map((v, i) => [+x(i).toFixed(1), +y(v).toFixed(1)]);
let g = '';
[40, 60, 80, 100, 120].forEach((t) => {
g += '<line class="grid" x1="' + pl + '" x2="' + W + '" y1="' + y(t) + '" y2="' + y(t) + '"/><text x="0" y="' + (y(t) + 4) + '">' + t + '</text>';
});
const line = smoothPath(pts);
host.innerHTML = '<svg viewBox="0 0 ' + W + ' ' + H + '" preserveAspectRatio="none" aria-hidden="true">' + g +
'<path class="chart-area" d="' + line + 'L' + pts[n - 1][0] + ',' + (H - pb) + 'L' + pts[0][0] + ',' + (H - pb) + 'Z"/>' +
'<path class="chart-line" d="' + line + '" vector-effect="non-scaling-stroke"/>' +
'<circle class="chart-dot" r="5" cx="' + pts[n - 1][0] + '" cy="' + pts[n - 1][1] + '"/></svg>';
host.dataset.n = n;
host._data = data;
};
group.addEventListener('change', (e) => draw(+e.target.value));
window.addEventListener('resize', () => draw(cur));
host.addEventListener('mousemove', (e) => {
const data = host._data;
if (!data) return;
const r = host.getBoundingClientRect();
const i = Math.max(0, Math.min(data.length - 1, Math.round(((e.clientX - r.left) / r.width - pl / W) / (1 - (pl + 8) / W) * (data.length - 1))));
let tip = host.querySelector('.chart-tip');
if (!tip) { tip = document.createElement('div'); tip.className = 'chart-tip'; host.appendChild(tip); }
tip.textContent = '$' + Math.round(data[i] * 112).toLocaleString();
tip.style.left = (pl + (i / (data.length - 1)) * (W - pl - 8)) / W * 100 + '%';
tip.style.top = (10 + (1 - (data[i] - 40) / 80) * (H - 34)) / H * 100 + '%';
});
host.addEventListener('mouseleave', () => { const t = host.querySelector('.chart-tip'); if (t) t.remove(); });
draw(30);
}
function initSparks() {
document.querySelectorAll('.spark').forEach((el, k) => {
const n = 24, data = seeded(n, 31 + k * 17), W = 200, H = 56;
const lo = Math.min(...data), hi = Math.max(...data);
const pts = data.map((v, i) => [(i / (n - 1)) * W, 4 + (1 - (v - lo) / (hi - lo)) * (H - 8)]);
const line = smoothPath(pts);
el.innerHTML = '<svg viewBox="0 0 ' + W + ' ' + H + '" preserveAspectRatio="none" aria-hidden="true"><path class="chart-area" d="' + line + 'L' + W + ',' + H + 'L0,' + H + 'Z"/><path class="chart-line" style="stroke-width:2" vector-effect="non-scaling-stroke" d="' + line + '"/></svg>';
});
}
function initAdminNav() {
const nav = document.getElementById('adminNav');
if (!nav) return;
nav.addEventListener('click', (e) => {
const l = e.target.closest('.nav-link');
if (!l) return;
e.preventDefault();
nav.querySelectorAll('.nav-link').forEach((x) => { x.classList.remove('active'); x.removeAttribute('aria-current'); });
l.classList.add('active');
l.setAttribute('aria-current', 'page');
});
}
initBigChart();
initSparks();
initAdminNav();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.