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

solid-mason

v0.2.0

Published

Masonry layout for SolidJS

Readme

solid-mason

Masonry layout for SolidJS

NPM Open in StackBlitz

A masonry grid packs items of differing heights into columns without leaving the gaps a plain column layout would. solid-mason measures each child and places it into the shortest column at the time it is visited, then sizes the container to its tallest column so the grid still occupies space in the document flow.

Install

npm i solid-mason
yarn add solid-mason
pnpm add solid-mason

The package ships both ESM and CommonJS builds, and has solid-js as a peer dependency.

Usage

import { Mason } from 'solid-mason';

<Mason as="div" columns={5} items={photos()}>
  {(photo, index) => <Photo src={photo.src} index={index()} />}
</Mason>;

items is the data, and the child function renders one element per item. Every prop Mason does not use is forwarded to the container element, so class, id, event handlers and the rest work as they do on a plain div.

Responsive columns

createMasonryBreakpoints watches a list of media queries and reports the column count of the matching one, ready to hand to columns:

import { Mason, createMasonryBreakpoints } from 'solid-mason';

const breakpoints = createMasonryBreakpoints(() => [
  { query: '(min-width: 1536px)', columns: 6 },
  { query: '(min-width: 1280px) and (max-width: 1536px)', columns: 5 },
  { query: '(min-width: 1024px) and (max-width: 1280px)', columns: 4 },
  { query: '(min-width: 768px) and (max-width: 1024px)', columns: 3 },
  { query: '(max-width: 768px)', columns: 2 },
]);

<Mason columns={breakpoints()} items={photos()}>
  {(photo) => <Photo src={photo.src} />}
</Mason>;

Changing the container element

as picks the tag, and the props of that tag are type-checked:

<Mason as="ul" columns={3} items={items()} aria-label="Gallery">
  {(item) => <li>{item.title}</li>}
</Mason>

API

<Mason />

| Prop | Type | Default | Description | | ---------- | -------------------------------------------------- | ------- | ---------------------------------------------------------------- | | columns | number | — | Number of columns. Values below 1 are clamped to 1. | | items | Data[] \| null \| undefined | — | Items to render, one child per item. | | children | (item: Data, index: () => number) => JSX.Element | — | Renders one item. index is an accessor, as with Solid's For. | | as | keyof JSX.HTMLElementTags | 'div' | Tag name for the container element. | | style | JSX.CSSProperties \| string | — | Extra container styles, merged with the ones the layout needs. | | ref | HTMLElement \| ((el: HTMLElement) => void) | — | Receives the container element. Mason keeps its own as well. |

Layout re-runs when items or columns change, when the window resizes, and when children are added or removed, always batched onto the next animation frame.

createMasonryBreakpoints(breakpoints, defaultColumns?)

Returns an accessor for the column count of the matching breakpoint.

  • breakpoints: accessor for a list of { query, columns }. Re-reading it re-subscribes, so the list can itself be reactive.
  • defaultColumns: column count before any query matches. Defaults to 1.

Breakpoints are evaluated in order, so when two queries match at the same time the later one wins. Write them from widest to narrowest, or make them mutually exclusive.

This reads window.matchMedia, so under SSR the accessor stays at defaultColumns until hydration.

MASON_KEY

The data-solid-mason attribute name. Mason writes the current column count there, which gives a page or a test a way to find a container and read its column count without reaching into the component.

Notes

  • Placement follows the shortest column at insertion time. It is not a balanced partition of the whole list, so the last column can end up noticeably shorter than the rest.
  • A child has to have its final height on first paint. Content that grows afterwards, such as an image without a reserved aspect ratio, will overlap its neighbours until something else triggers another pass. Give media an aspect-ratio or an explicit height, as the demo does.
  • Children are absolutely positioned, so margins on them collapse out of the layout. Pad the child's own wrapper instead.

Demo

pnpm install
pnpm --filter demo dev

Sponsors

Sponsors

License

MIT © lxsmnsyc