CSS Grid Was Never the Full Solution
When CSS Grid arrived, frontend developers celebrated.
Finally:
real 2D layouts
proper alignment
responsive structure without hacks
But then real projects happened.
Cards. Dashboards. Product listings. Editorial layouts.
And suddenly:
Nested grids stopped aligning properly.
You’ve probably seen this:
Card titles misaligned
Footers jumping around
Product cards with inconsistent heights
Layout systems breaking under dynamic content
Not because Grid is bad.
Because nested grids were isolated from parent tracks.
That’s exactly what subgrid fixes.
The Core Problem
Imagine a product grid:
Title
Description
Traditional nested grid:
.products {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.card {
display: grid;
grid-template-rows: auto 1fr auto;
}
Looks fine initially.
Until:
descriptions vary in length
content becomes dynamic
buttons stop aligning
Now your UI feels visually messy.
Enter subgrid
.card {
display: grid;
grid-template-rows: subgrid;
}
This allows child grids to inherit track sizing from the parent grid.
Meaning:
alignment becomes consistent
spacing becomes shared
layouts become structurally aware
This is huge for design systems.
What subgrid Actually Changes
Without subgrid:
nested grids calculate independently
With subgrid:
child grid participates in parent layout structure
Think of it like:
Nested layout synchronization.
Before vs After
❌ Traditional Nested Grid
.card {
display: grid;
grid-template-rows: auto 1fr auto;
}
Each card:
sizes independently
creates inconsistent alignment
✅ Using subgrid
.products {
display: grid;
grid-template-rows: auto 1fr auto;
}
.card {
display: grid;
grid-row: span 3;
grid-template-rows: subgrid;
}
Now:
titles align
descriptions align
buttons align
Without JS height calculations.
Real-World Use Cases
1. Product Cards
Perfect for:
ecommerce grids
pricing sections
comparison tables
2. Editorial Layouts
Articles with:
metadata
previews
footers
author blocks
can stay visually aligned.
3. Dashboard Widgets
Analytics cards often contain:
headers
graphs
actions
subgrid keeps everything structurally consistent.
React Developers Should Care About This
React developers often solve layout inconsistency using:
JS measurements
ResizeObservers
equal-height hacks
flexbox compromises
Example: