Full-Height Sidebar Patterns
You'll learn how to create sticky sidebars and navigation that span the full viewport height using CSS Grid's natural layout capabilities.
The Core Idea
A full-height sidebar pattern creates a layout where the sidebar stretches from the top to the bottom of the viewport, often with navigation that "sticks" in place while the main content scrolls. CSS Grid makes this remarkably simple by letting you define track sizes based on viewport units and controlling how child elements fill available space.
How It Works
Think of your screen like a sheet of paper divided into columns. You want the left column (sidebar) to always reach from top to bottom, even if it doesn't have much content. Meanwhile, the main content area should scroll independently if it's too long.
The key is setting your grid container to height: 100vh (full viewport height) and defining columns with fixed or fractional units. The grid automatically distributes this height to its rows, making the sidebar naturally stretch full-height.
.layout {
display: grid;
grid-template-columns: 250px 1fr;
height: 100vh;
}
.sidebar {
overflow-y: auto; /* Scrolls if sidebar content is too long */
position: sticky;
top: 0;
}
.main-content {
overflow-y: auto; /* Main content scrolls independently */
}
The sidebar gets a fixed width (250px), while the main content gets the remaining space (1fr). By setting overflow-y: auto on each section, they scroll independently when needed.
When to Use This
This pattern works beautifully for dashboards, documentation sites, admin panels, or any application with persistent navigation. Grid handles the height distribution automatically—no manual calculations or absolute positioning required.
Key Takeaway: CSS Grid's viewport-based height (100vh) combined with independent scrolling (overflow-y) creates professional full-height sidebar layouts with minimal code.