Tutorials ·
How to Build an Unsplash-Style Masonry Image Grid in React
UI Layouts
On this page
Masonry organizes images of different heights into a balanced collection without forcing identical aspect ratios.
Live example from UI Layouts
Misty Mountain Majesty
Winter Wonderland
Autumn Mountain Retreat
Tranquil Lake Reflection
Misty Mountain Peaks
Golden Hour Glow
Snowy Mountain Highway
Foggy Mountain Forest
Sunset Mountain Silhouette
Alpine Meadow Bliss
Mountain Lake Serenity
Icy Mountain Stream
Wildflower Mountain Meadow
Mountain Valley Vista
Rugged Mountain Terrain
Mountain Wildflower Bloom
Mountain River Rapids
Lush Mountain Valley
Choose the layout trade-off
CSS columns are simple but flow vertically before the next column. A measured masonry layout can balance heights, but needs resize and loading logic.
Reserve each image ratio
Use known width and height metadata before loading to reduce layout shifts. Maintain the original aspect ratio where the image itself is the content.
Keep order understandable
Preserve a meaningful DOM order for keyboard and screen-reader users. Test narrow screens and dynamic insertion without jumping the current scroll position.
Implementation pattern
The following focused snippet demonstrates the principle, not the complete UI Layouts implementation. The live example and linked documentation contain the full source.
.masonry { columns: 3 15rem; column-gap: 1rem; }
.masonry > * { break-inside: avoid; margin-bottom: 1rem; }
Explore the source
Open the masonry grid component documentation for the full implementation, examples and any required dependencies. Test the interaction on a narrow screen and with keyboard navigation before adapting it to production.