CSS Grid Lanes (Masonry Layout) Is Here: A Complete Guide for 2026
<blockquote> <p><em>Originally published on <a href="https://nextfuture.io.vn/en/blog/css-grid-lanes-masonry-layout-guide-2026" rel="noopener noreferrer">NextFuture</a></em></p> </blockquote> <p>Pinterest-style masonry layouts used to require JavaScript hacks, heavyweight libraries, or Flexbox column tricks that broke reflow. Not anymore. In 2026, <strong>CSS Grid Lanes</strong> (formerly known as the masonry proposal) is the native browser answer — and Safari 26 just shipped it first.</p> <p>If you've ever built a card grid where items have variable heights and wanted them to pack tightly without gaps, this is the feature you've been waiting for. Let's dig in.</p> <h2> What Are CSS Grid Lanes? </h2> <p>CSS Grid Lanes adds a new display mode that creates a masonry-style layout using the fa
Originally published on NextFuture
Pinterest-style masonry layouts used to require JavaScript hacks, heavyweight libraries, or Flexbox column tricks that broke reflow. Not anymore. In 2026, CSS Grid Lanes (formerly known as the masonry proposal) is the native browser answer — and Safari 26 just shipped it first.
If you've ever built a card grid where items have variable heights and wanted them to pack tightly without gaps, this is the feature you've been waiting for. Let's dig in.
What Are CSS Grid Lanes?
CSS Grid Lanes adds a new display mode that creates a masonry-style layout using the familiar grid syntax. Items flow into the axis with the most available space, resulting in a tightly packed layout without the ugly gaps you get with regular grid rows.
The specification settled on the grid-lanes keyword rather than the earlier masonry proposal after years of debate between browser vendors. Here's the minimal syntax:
.masonry-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: masonry; /* triggers masonry packing on the row axis */ gap: 1rem; }.masonry-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: masonry; /* triggers masonry packing on the row axis */ gap: 1rem; }Enter fullscreen mode
Exit fullscreen mode
That's it. No JavaScript. No ResizeObserver. No position calculations. The browser handles all the packing logic natively.
Progressive Enhancement: Support Both Old and New
Since Grid Lanes is only in Safari 26 right now (Chrome and Firefox support is coming), you'll want a progressive enhancement fallback. Use @supports:
/* Fallback: regular grid for unsupported browsers */ .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; align-items: start; /* prevents cards from stretching to row height */ }/* Fallback: regular grid for unsupported browsers */ .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; align-items: start; /* prevents cards from stretching to row height */ }/* Enhancement: masonry for supported browsers */ @supports (grid-template-rows: masonry) { .card-grid { grid-template-rows: masonry; } }
/* Future syntax using grid-lanes keyword */ @supports (display: grid-lanes) { .card-grid { display: grid-lanes; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; } }`
Enter fullscreen mode
Exit fullscreen mode
React + Tailwind: Building a Masonry Image Gallery
Here's a practical React component that uses CSS Grid Lanes with a Tailwind-compatible class and graceful fallback:
// components/MasonryGrid.tsx interface MasonryGridProps { children: React.ReactNode; columns?: 2 | 3 | 4; gap?: string; }// components/MasonryGrid.tsx interface MasonryGridProps { children: React.ReactNode; columns?: 2 | 3 | 4; gap?: string; }export function MasonryGrid({ children, columns = 3, gap = "1rem" }: MasonryGridProps) { return (
{children}
); }
// Usage export default function PhotoGallery({ photos }: { photos: Photo[] }) { return (
{photos.map((photo) => (
{photo.caption}
))}
); }`
Enter fullscreen mode
Exit fullscreen mode
The Old Way vs. The New Way
Before Grid Lanes, the most common technique was the CSS column hack:
/* The old column hack — has serious ordering problems */ .masonry-old { columns: 3; column-gap: 1rem; }/* The old column hack — has serious ordering problems */ .masonry-old { columns: 3; column-gap: 1rem; }.masonry-old > * { break-inside: avoid; margin-bottom: 1rem; } /* Problem: items flow top-to-bottom per column, not left-to-right / / Screen readers and keyboard nav get confused /`
Enter fullscreen mode
Exit fullscreen mode
The column hack has two fatal flaws: items are ordered vertically (top of column 1, top of column 2…) rather than naturally, and it breaks accessibility because the DOM order doesn't match visual order. CSS Grid Lanes preserves DOM order, which is a massive win for accessibility and keyboard navigation.
When to Use Grid Lanes
-
Photo galleries with variable image heights
-
Card grids with different content lengths (blog posts, products, testimonials)
-
Dashboard widgets that have different content densities
-
Pinterest/Dribbble-style layouts
When NOT to Use Grid Lanes
-
When you need precise row alignment across columns (use regular grid)
-
When items should maintain consistent row heights (use grid with align-items: stretch)
-
When you need complex spanning behavior
Browser Support Timeline
As of early 2026, CSS Grid Lanes is available in Safari 26 (first to ship). Chrome and Firefox have the feature behind experimental flags and are expected to ship stable support later in 2026. The @supports progressive enhancement approach means you can write the code today and your layout will just get better for users as browser support expands.
Actionable Takeaways
-
Start writing grid-template-rows: masonry in your grid styles today — Safari users see the improvement immediately
-
Always pair with @supports and a fallback — regular grid with align-items: start looks decent on non-supporting browsers
-
Ditch the CSS column hack for new projects — it has accessibility problems that Grid Lanes solves natively
-
Keep an eye on the MDN CSS Grid docs — browser compatibility data for Grid Lanes is already being tracked there
This article was originally published on NextFuture. Follow us for more frontend & AI engineering content.
DEV Community
https://dev.to/bean_bean/css-grid-lanes-masonry-layout-is-here-a-complete-guide-for-2026-4686Sign in to highlight and annotate this article

Conversation starters
Daily AI Digest
Get the top 5 AI stories delivered to your inbox every morning.
More about
availableproductfeatureThe Gemini-powered features in Google Workspace that are worth using - TechCrunch
<a href="https://news.google.com/rss/articles/CBMipgFBVV95cUxQWFAwYW8yX3JlQzRSUlVKR1JoUlhGSndEeFR6V1RsQTJLUEl1UkpaUk5kSFY5dW1raEJoTmRSUVNobG5CNU9DdDl4cXJEU3p6T2tKdXpXdlpaeDRYYTAtazNaaC1fZ3NYVXQ5dzE0Z2podXFqeVpaUFhIay1XUEZ2Y0Z2a1FlYno5MlJJdTQwY21oSnFOYnVLN2lDblRYSjdrdkdROFN3?oc=5" target="_blank">The Gemini-powered features in Google Workspace that are worth using</a> <font color="#6f6f6f">TechCrunch</font>
Exclusive | The Sudden Fall of OpenAI’s Most Hyped Product Since ChatGPT - WSJ
<a href="https://news.google.com/rss/articles/CBMiogNBVV95cUxQTTEtQW5SNGpDTTF0OEszb2ZxRGphd0VJZnFFZ2FnTFFiclFMT3pPeFVoaUFPODRUWFprWEkzLV9Tb1hKMnpPV1o1aGNVaDJydDl5WkxuTFFRMG9aTHVHS3RZS1VVdHZCbTlhakVZdThQeUJFcFZFWXJTQ09XSmx6aGgyQ2NQT2ZGNURZZ01naXNnR1ViUHczdkhTaHJIVWJIZWdrR2wzbXNGUXNfdV9QWDZmTkltWmc5MjROd255YVp5ZGpBREFJWTNkZ0stdURJZHMxMXA3NEh0eHJLTERLMWhZNk1yWFVELWY5TjVQQVN1UUZUZkVOc2psVE9KVm1sUGRuR0JBSFlIWWNXSU1GSnZ3U1cwZDBYcmIxNW5lLXBVTDFYMHhYeGFDWWl0LUViRENKREZEaWxBUXZnbkticEp0YnBmVWlKS1ZEVmdMS29ETlZBLV9kRHRKZmVpYi1RX0NaeFZkU2dGMFVkZUtSclRlNTlxZlNKMTdzYVpnd2s5N1VWSm1JeG9VSUN6SjRkSWI3YkpzeHdnN0k1UFpQcGJB?oc=5" target="_blank">Exclusive | The Sudden Fall of OpenAI’s Most Hyped Product Since ChatGPT</a> <font color="#6f6f6f">WSJ</font>
Exclusive | The Sudden Fall of OpenAI’s Most Hyped Product Since ChatGPT - WSJ
<a href="https://news.google.com/rss/articles/CBMiogNBVV95cUxPdWZxdW04TlM1c0hETkFQYy1vb3ZnUnh5cU1aaFM0dzBDS213OW9hR2tFSVVXb25MTXV0QkJuMEVpUjJUcWlOUmZLWlZsdk85cVJuODhEeXBEQlBTQkIwT1VZN0t2RFhEd2lLcnhQbm5FX3cxVnN6VXMzNjFxRnVLR2NkbjRWY0tiazIyMnRCZTlfWXBxcXZDXzl2ZEt4Ty15MTc2Mm5lWTh6Q05LbHo3bDRhYmdQN1FucDI1czc3NFQ1dTZuSkhNenF1V09qa3VLQmw3UjVUbWYyallHUGNHYmluOElxajBHb3dMa3JEejhlZEFIYWhvaUM4azZpVHFHaDNqLXA2RjRpdzBXRjg2OVRqM0JLTHJEeWZPZEhUMVYxeFR5NmxTMzdGdVJvcGxhNlBxS3JKUE55ZTRxeHBBM0VnZkJ2N2FCNlNGN1VkcGZCZlJxV3NmZlZsYnV1RHBzREdMQmpYM20wSEpuNzF5VmhfMnZEeWFNeUpnVzZIaEhPT2MzLWtwcGNtZ2dwQXd6VWY4MHFhX09aM05BM1J3WENR?oc=5" target="_blank">Exclusive | The Sudden Fall of OpenAI’s Most Hyped Product Since ChatGPT</a> <font color="#6f6f6f">WSJ</font>
Knowledge Map
Connected Articles — Knowledge Graph
This article is connected to other articles through shared AI topics and tags.
More in Products
NEW Webcast | One workflow, every tool: how AI-native ELN is changing drug discovery - Scientific Computing World
<a href="https://news.google.com/rss/articles/CBMivwFBVV95cUxNVVlmeHFEcEVJOC1qU2tUQmx2WXBObWp3V3pSZzFHbXEwc0dZUUhqOEZiaDZhNVptMTR3X1prMm94cmhWdDRZb3BFWWowWXd6akNwV0lpM2pySmpmRnNWVWYyUTZYVFVQX09mMHh3WHhtdC1MRWJxVlpiQUVObk1FNEQwUDhYR0YtRm5LWjd1VkRUQkNneTZaZnMxd29NcmFFYTJVcUZSMkczN2o4Zi1OWG1nM0Vtd2FqNDdwQnJhTQ?oc=5" target="_blank">NEW Webcast | One workflow, every tool: how AI-native ELN is changing drug discovery</a> <font color="#6f6f6f">Scientific Computing World</font>
DHL Supply Chain appointed by Air France - Freightweek
<a href="https://news.google.com/rss/articles/CBMinwFBVV95cUxNSDU0RXhIcWdSbXRPUTlNVktaeUU4S0Z0enRKZ3FobGxzaTg4ME1Ubll2bEdpZ01Pc1VSNHB1NFI2ZGxfckFySGtSRjdGVjdKOXZiNjl4eF96SVBpRlp4czREcVUzYVA3QWw0Q0U5a3VrNEhfZmpTNEprbk93VGU0Zm1zVHRXU0xIRWlDOGpRX0Z5bk1iNm9GS1pUcTVybkU?oc=5" target="_blank">DHL Supply Chain appointed by Air France</a> <font color="#6f6f6f">Freightweek</font>
YouTube blasted by hundreds of experts over ‘AI slop’ videos served up to kids - Fast Company
<a href="https://news.google.com/rss/articles/CBMimwFBVV95cUxOdGZGVWUzcVI4Zmh1emVwYmRTSGp4dWFOZGZaazI0eEdrVHQ3RW95OG1sWURycGRDN2c4VVNzOXdobXYxWHpObW5rVHNPeDJsQ1Z4YU9QTGcxdno2RW5PeVI4ZDNOQk1ONm0wd1ZZN0hhS01CZUtWeXJuc21ldzNPVUpKNXNBVVd1dmhWZjhPWEU2aFl1VmFLcmVWdw?oc=5" target="_blank">YouTube blasted by hundreds of experts over ‘AI slop’ videos served up to kids</a> <font color="#6f6f6f">Fast Company</font>
TikTok ran ads for AI apps that digitally undress people in photos - AOL.com
<a href="https://news.google.com/rss/articles/CBMidEFVX3lxTE1VMGdQUTlwNU8wNXBqLXc5TVZ6TG9IcFVUc0RmR0dJbkY0SUN3M05QWXFhRDRmQWI5dFJTeVNvVWhudVFHb24yX1RfLU0tV3FlUWktSnpEVmcyUEc5TDJLQkxXdDR3aDdaS3d5LVQxNlIxRXVO?oc=5" target="_blank">TikTok ran ads for AI apps that digitally undress people in photos</a> <font color="#6f6f6f">AOL.com</font>
Discussion
Sign in to join the discussion
No comments yet — be the first to share your thoughts!