npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@masonrygrid/react

v0.9.4

Published

Masonry grid component for React

Readme

@masonrygrid/react

A responsive column masonry layout for React. Build flexible grids where items naturally fill the space around them, with responsive independent column control over how much space each item occupies.

Install

npm install @masonrygrid/react

Requires React 18 or newer.

Basic usage

import { MasonryGrid } from '@masonrygrid/react';

const heights = [227, 295, 352, 292, 180, 260];

const Demo = () => {
  return (
    <MasonryGrid spacing="1rem">
      {heights.map((height, index) => (
        <MasonryGrid.Item key={index} colSpan={{ lg: 4 }}>
          <div style={{ height, outline: "1px solid black" }} className="item"></div>
        </MasonryGrid.Item>
      ))}
    </MasonryGrid>
  );
};

MasonryItem is also available as a named export if you prefer it over MasonryGrid.Item.

Demo

see: live playground

MasonryGrid

| Prop | Type | Default | Description | | --------- | -------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------ | | spacing | number \| string \| { x?: number \| string; y?: number \| string } | "1rem" | Space between items. Numbers are pixels, strings can be any CSS length. Use an object to set each axis separately. |

It also accepts every attribute of a div (className, style, id, data-*, aria-*, event handlers...).

MasonryGrid.Item

| Prop | Type | Default | Description | | --------- | ------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- | | colSpan | number \| "auto" \| "fill" \| ResponsiveColSpan | "auto" | Columns the item spans out of 12. "auto" sizes it to its content and "fill" makes it take the remaining space of the row. |

It also accepts every attribute of a div.

Responsive colSpan

Pass an object to change the span per breakpoint. Each value applies from that screen width upwards (min-width):

| Key | From | | ----- | ------ | | xs | 320px | | sm | 576px | | md | 768px | | lg | 992px | | xl | 1200px | | xxl | 1400px |

<MasonryGrid.Item colSpan={{ xs: 12, md: 6, xl: 3 }}>...</MasonryGrid.Item>

Things to know

  • Items must be direct children of MasonryGrid. Conditional rendering such as {show && <MasonryGrid.Item />} works; wrapping items in a fragment does not.
  • The layout is calculated in the browser. Items are measured and placed after the first render, and recalculated whenever the grid or any item changes size (for example, when an image finishes loading). With server rendering, the grid takes its final layout after hydration.
  • Don't pass index, topOffset or items to MasonryGrid.Item. They are injected by MasonryGrid.

Styles

The styles are injected into the page when the package is loaded