Dashboard Layout — CSS Grid Structure
/* ── Full dashboard layout ─────── */
.dashboard {
display: grid;
grid-template-columns: 240px 1fr;
grid-template-rows: 60px 1fr;
min-height: 100vh;
}
.topbar { grid-column: 1 / -1 }
.sidebar { grid-row: 2 }
.main { grid-row: 2; overflow-y: auto }
/* ── KPI card grid ─────────────── */
.kpi-grid {
display: grid;
grid-template-columns:
repeat(auto-fill, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
Chart.js Quick Integration
<!-- 1. Add Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- 2. Canvas element -->
<canvas id="revenueChart"></canvas>
/* 3. Init chart */
new Chart(document.getElementById('revenueChart'), {
type: 'line',
data: {
labels: ['Jan','Feb','Mar','Apr','May'],
datasets: [{
label: 'Revenue',
data: [12000,19000,15000,22000,28000],
borderColor: '#a78bfa',
tension: 0.4
}]
}
});
Frequently Asked Questions
How do I create an admin dashboard in HTML CSS?
Dashboard layout: CSS Grid with `grid-template-columns: 240px 1fr` (sidebar + main). Topbar spans full width with `grid-column: 1 / -1`. KPI cards in a `repeat(auto-fill, minmax(200px, 1fr))` grid below. Add Chart.js for charts (60KB, no dependencies). Use CSS custom properties for the color system — easy theme switching between light and dark. Full layout code above.
What is the best free HTML admin dashboard template?
Best free HTML dashboard templates: AdminLTE (Bootstrap-based, 400+ components, MIT). Tabler (Bootstrap 5, 100+ pages, MIT). CoreUI (free tier, Bootstrap/React versions). UIXDraft ($35, 180+ templates including dark dashboard — commercial license, PageSpeed optimized). Tabler is the best free option for new projects; UIXDraft is best for agencies delivering to clients.
How do I add charts to an HTML dashboard?
Chart.js (free, 60KB CDN): `<script src='https://cdn.jsdelivr.net/npm/chart.js'></script>`. Add `
How do I make a dashboard sidebar collapsible?
Toggle approach: JS adds/removes `.collapsed` class on the sidebar. CSS: `.sidebar{width:240px;transition:width .3s}` and `.sidebar.collapsed{width:60px;overflow:hidden}`. Hide text labels (`.sidebar.collapsed .nav-label{display:none}`), keep icons visible. Store collapsed state in `localStorage.setItem('sidebar','collapsed')` and restore on page load. UIXDraft dashboard templates include this pattern pre-built.
What data can I display in an HTML dashboard without a backend?
Static HTML dashboards can display: hardcoded data (works for demos and client mockups), localStorage data (user preferences, simple app state), CSV files loaded with PapaParse.js, JSON files fetched with `fetch('/data.json')`, browser APIs (geolocation, notifications, device memory), and third-party APIs with CORS headers (OpenWeather, CoinGecko, GitHub API). For real-time backend data: connect to Supabase, Firebase, or your own REST API.