React Masonry Libraries Compared
Most React masonry libraries take one of two routes. Some deal the items into column divs by index, which leaves the columns uneven and breaks the reading order. Others render the items, measure them and move them into place, so the grid jumps as images load and renders several times after hydration.
Masonry Grid takes a third route. The browser places the frames in a CSS Grid, and the layout is computed from the aspect ratio of each frame, which is known before a single image loads. Nothing jumps, the DOM stays in source order, and the server renders the whole grid.
The facts below were checked in December 2026 against the latest version of each package. The sizes are the package with its dependencies, bundled with esbuild without React, minified and compressed with brotli.
At a Glance
Section titled “At a Glance”| Library | Even columns | As images load | Columns follow | Server markup | Size | Released |
|---|---|---|---|---|---|---|
| Masonry Grid | Yes | Nothing moves | Container | Full grid | 2.3 kB | Dec 2026 |
| react-masonry-css | No | Items shift down | Window | Full | 1.2 kB | Apr 2021 |
| react-responsive-masonry | After measuring | Items change columns | Container | Full | 3.0 kB | Sep 2026 |
| masonic | After measuring | Cells are moved | Container, on window resize | None | 5.7 kB | Apr 2025 |
| react-plock | In balanced mode, after measuring | Items shift or change columns | Window | Empty | 0.9 kB | Oct 2025 |
| react-masonry-component | After measuring | The grid lays out again | Window | Unplaced items | 25.6 kB | Jul 2021 |
Items shift as images load when the images have no size set. Giving every image its size up front is the usual cure for this layout shift, and that size is all Masonry Grid needs to lay out the whole grid.
Column Divs: Uneven Columns, Broken Order
Section titled “Column Divs: Uneven Columns, Broken Order”react-masonry-css deals the children into N column divs by index: item 1 goes to column 1, item 2 to column 2, and so on. It never looks at heights, so a column that happens to get tall items ends far below the others. The column count comes from breakpointCols, matched against the window width, so a grid in a sidebar gets the column count meant for the whole page. Its last release came out in April 2021.
react-responsive-masonry starts the same way, then measures every item after mount and moves each one to the shortest column. Every change of an item’s height, like an image that has loaded, starts the distribution again, so items jump between columns while the page loads. With ResponsiveMasonry, the server renders the column count of the smallest breakpoint, and the grid renders at least twice more after hydration.
react-plock deals items the same way into a CSS Grid of column grids: by index, or by measured height with useBalancedLayout. It takes the column count from matchMedia in an effect and renders nothing until then, so the server markup is empty and the grid appears only after JavaScript runs.
In all three, every item sits inside a column div. The DOM order, which the keyboard and screen readers follow, goes down the first column before the second one.
Measure and Move: masonic and react-masonry-component
Section titled “Measure and Move: masonic and react-masonry-component”masonic renders the cells hidden, reads their heights, then positions every cell absolutely in the shortest column. It needs a browser: on the server it throws because ResizeObserver is not defined, and its author says that rendering it on the server does not make sense. Items must be objects, and positions are cached by index, so removing items needs a new positioner. In return, it virtualizes: it renders only the cells near the viewport.
react-masonry-component wraps the jQuery-era Masonry and imagesLoaded: it measures every item, positions it absolutely and lays the grid out again as images load. Its last release, from 2021, declares React 17 as the newest peer, so npm refuses to install it next to React 19 without --legacy-peer-deps. With its dependencies it weighs 25.6 kB, eleven times as much as Masonry Grid.
Masonry Grid: Layout from Aspect Ratios
Section titled “Masonry Grid: Layout from Aspect Ratios”Masonry Grid lets the browser do the placing: CSS Grid fills the rows in source order and takes the column count from grid-template-columns. RegularMasonryGrid then pulls every frame up to the one above it with transform: translateY, and BalancedMasonryGrid also reorders frames inside rows with the CSS order property to even out the columns.
- Nothing jumps. Every
Framedeclares itswidthandheight, and the layout is computed from these ratios, not from measured content. A frame has its final size before its image arrives, so images that load late change nothing. - The order stays. The DOM keeps the source order for the keyboard and screen readers, and
RegularMasonryGridkeeps the visual order too. - It follows its container.
frameWidthsets the minimum column width, and aResizeObserverwatches the container, so the same grid fits a page, a sidebar or a modal. Resizing needs no new layout until the column count changes. - It renders on the server. The server renders the full grid with every frame at its final size, and the frames are pulled up as soon as the script runs.
SpannedMasonryGridneeds no script at all: its server markup is already the final layout. - It is small and maintained. 2.3 kB with every grid, 1.9 kB for
BalancedMasonryGridandFrame, released for React 19 in December 2026. - One layout for every framework. The same grids come for Preact, Svelte, SolidJS, Nanoviews and vanilla JavaScript.
Which One to Pick
Section titled “Which One to Pick”- Photos, videos, products, any cards with known proportions: Masonry Grid lays them out before anything loads.
- Server rendering and static sites: Masonry Grid renders the whole grid on the server, and
SpannedMasonryGridlays it out without JavaScript. - Accessible order: Masonry Grid keeps the DOM in source order, where column
divs go column by column. - A small bundle: Masonry Grid. react-masonry-css and react-plock are smaller only because they deal items by index, and react-plock can even out the columns only by measuring them after render.
- Infinite scroll: Masonry Grid lays out new frames as they are rendered, with nothing to call, see the infinite scroll example.
- Tens of thousands of items in one list: masonic, which renders only the cells near the viewport.
- An existing Masonry setup: see Migrating from Masonry.
Switch to Masonry Grid
Section titled “Switch to Masonry Grid”A grid of photos with react-masonry-css:
import Masonry from 'react-masonry-css'
<Masonry breakpointCols={{ default: 4, 1100: 3, 700: 2 }} className='grid' columnClassName='grid-column'> {photos.map(photo => ( <img key={photo.id} src={photo.src} alt={photo.alt} /> ))}</Masonry>The same grid with react-responsive-masonry:
import Masonry, { ResponsiveMasonry } from 'react-responsive-masonry'
<ResponsiveMasonry columnsCountBreakPoints={{ 350: 1, 750: 2, 900: 3 }}> <Masonry gutter='10px'> {photos.map(photo => ( <img key={photo.id} src={photo.src} alt={photo.alt} /> ))} </Masonry></ResponsiveMasonry>And with Masonry Grid:
import { BalancedMasonryGrid, Frame } from '@masonry-grid/react'
<BalancedMasonryGrid frameWidth={250} gap={10}> {photos.map(photo => ( <Frame key={photo.id} width={photo.width} height={photo.height}> <img src={photo.src} alt={photo.alt} /> </Frame> ))}</BalancedMasonryGrid>The breakpoints are gone: frameWidth is the minimum column width, and the grid fits as many columns as its container allows. Every Frame gets the size of its photo, and the CSS for the column divs is no longer needed. The content of a frame must not stretch it, Troubleshooting shows how.