Skip to main content

Lesson 7 of 10

Dashboard Layout with Grid

Build a complete dashboard layout using CSS Grid. Dashboards require precise control over widget sizes, spanning, and responsive behavior - perfect for showcasing Grid's two-dimensional power.

15 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Dashboard Grid Strategy

  • Fixed sidebar + fluid content - grid-template-columns: 250px 1fr for sidebar layout
  • Widget grid - repeat(auto-fit, minmax(250px, 1fr)) for responsive widget cards
  • Header spanning - grid-column: 1 / -1 for full-width dashboard header
  • Tall/wide widgets - Use span for KPI cards and charts that need more space
  • Nested grids - Widgets themselves can be grid or flex containers for internal layout
  • Sticky sidebar - Combine position: sticky with grid for a sidebar that scrolls with content

Dashboard Layout Code

Dashboard Layout Code
/* Dashboard page layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar content";
  min-height: 100vh;
}

.dashboard-sidebar { grid-area: sidebar; background: #1a1a2e; }
.dashboard-header  { grid-area: header; background: #16213e; }
.dashboard-content { grid-area: content; padding: 24px; }

/* Widget grid inside content */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: minmax(150px, auto);
  gap: 20px;
}
.widget-wide { grid-column: span 2; }
.widget-tall { grid-row: span 2; }
.widget-full { grid-column: 1 / -1; } /* Chart = full width */

Tip

Make the dashboard sidebar sticky so it stays visible as users scroll through long content: position: sticky; top: 0; height: 100vh; overflow-y: auto. This keeps navigation accessible without JavaScript, using only CSS.

Diagram
Loading diagramโ€ฆ

CSS Grid excels at structuring full-page application dashboards with sidebar, nav, and widgets

Common Mistake

Hardcoding the sidebar width for every breakpoint. Instead, use grid-template-columns: clamp(200px, 20%, 280px) 1fr for a fluid sidebar that adapts between breakpoints while staying within a comfortable range. No media query needed for the sidebar alone.

Practice Task

Build a mini dashboard: (1) Two-column grid with 250px sidebar + 1fr content using grid-template-areas, (2) Inside the content area, add a widget grid with repeat(auto-fit, minmax(200px, 1fr)), (3) Make one widget span full width with grid-column: 1 / -1 for a chart section.

Quick Quiz

Key Takeaways

  • Build a complete dashboard layout using CSS Grid.
  • Fixed sidebar + fluid content - grid-template-columns: 250px 1fr for sidebar layout
  • Widget grid - repeat(auto-fit, minmax(250px, 1fr)) for responsive widget cards
  • Header spanning - grid-column: 1 / -1 for full-width dashboard header

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done