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-masonry-grid

v0.2.1

Published

A lightweight, responsive Masonry Grid component for SolidJS.

Readme

🧱 Solid Masonry Grid

npm version npm total downloads license bundle size

A lightweight, responsive Masonry Grid component for SolidJS, built without dependencies — ideal for creating dynamic, Pinterest-style layouts with ease.


✨ Features

  • 📦 Zero dependencies – pure SolidJS + inline styles
  • Automatic column adjustment based on breakpoints
  • 🎨 Customizable gaps between items
  • 🧩 Flexible rendering through the renderItem prop
  • 🪶 Lightweight and fast (under 2KB gzipped)

📦 Installation

npm install solid-masonry-grid

or using pnpm:

pnpm add solid-masonry-grid

🚀 Usage Example

Here’s a minimal example using the MasonryGrid component. gap and breakpoints are optional and fully customizable.

import { MasonryGrid } from 'solid-masonry-grid'

const images = [
  'https://placehold.co/300x200/orange/white?text=1',
  'https://placehold.co/400x400/red/white?text=2',
  'https://placehold.co/250x300/blue/white?text=3',
  'https://placehold.co/350x500/green/white?text=4',
  'https://placehold.co/500x350/yellow/white?text=5',
]

export default function App() {
  return (
    <main style={{ padding: '1rem' }}>
      <MasonryGrid
        items={images}
        gap={16} // optional, default is 12
        breakpoints={[
          { width: 0, columns: 1 },
          { width: 640, columns: 2 },
          { width: 900, columns: 3 },
          { width: 1200, columns: 4 },
        ]} // optional, default breakpoints applied if omitted
        renderItem={src => (
          <img
            src={src}
            alt="Masonry item"
            style={{
              width: '100%',
              borderRadius: '12px',
              objectFit: 'cover',
            }}
          />
        )}
      />
    </main>
  )
}

⚙️ API Reference

<MasonryGrid />

| Prop | Type | Default | Description | | ------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | items | T[] | required | Array of items to render | | renderItem | (item: T) => JSX.Element | required | Function to render each item | | gap | number | 12 | Space (in px) between elements | | breakpoints | { width: number; columns: number }[] | [{ width: 0, columns: 1 }, { width: 640, columns: 2 }, { width: 900, columns: 3 }, { width: 1200, columns: 4 }] | Defines how many columns are shown at each screen width |


🧠 How It Works

  • The grid listens to window resize events and dynamically adjusts the column count according to the provided breakpoints.
  • Items are distributed across columns in a round-robin fashion — ensuring a balanced layout even for varying item heights.
  • The layout is rendered using simple flexbox columns — no external CSS grid or masonry library required.

🧩 Example: Cards Layout

import { MasonryGrid } from 'solid-masonry-grid'

type Review = {
  id: number
  img: string
  title: string
  text: string
}

const reviews: Review[] = [
  {
    id: 1,
    img: 'https://placehold.co/300x200/orange/white?text=1',
    title: 'Excellent!',
    text: 'Loved it so much!',
  },
  {
    id: 2,
    img: 'https://placehold.co/400x400/red/white?text=2',
    title: 'Pretty good',
    text: 'Nice product overall.',
  },
  {
    id: 3,
    img: 'https://placehold.co/250x300/blue/white?text=3',
    title: 'Could improve',
    text: 'Some parts need work.',
  },
  {
    id: 4,
    img: 'https://placehold.co/350x500/green/white?text=4',
    title: 'Fantastic',
    text: 'Would buy again!',
  },
  {
    id: 5,
    img: 'https://placehold.co/300x200/yellow/white?text=5',
    title: 'Great product',
    text: 'Highly recommended.',
  },
  {
    id: 6,
    img: 'https://placehold.co/400x400/purple/white?text=6',
    title: 'Impressive',
    text: 'Excellent quality.',
  },
]

export default function ReviewList() {
  return (
    <MasonryGrid
      items={reviews}
      gap={20}
      renderItem={review => (
        <div
          style={{
            background: '#fff',
            overflow: 'hidden',
            borderRadius: '12px',
            boxShadow: '0 2px 6px rgba(0,0,0,0.1)',
          }}
        >
          <img
            loading="lazy"
            style={{ width: '100%', height: 'auto' }}
            src={review.img}
            alt={review.title}
          />
          <div style={{ padding: '1rem' }}>
            <h3 style={{ fontWeight: 600, marginBottom: '0.5rem', color: '#333' }}>
              {review.title}
            </h3>
            <p style={{ color: '#555' }}>{review.text}</p>
          </div>
        </div>
      )}
    />
  )
}

🧱 Tips

  • Use percentage widths or width: 100% for responsive child elements.
  • Consider using aspect-ratio or placeholders to avoid layout shift for images with varying heights.
  • The grid itself does not handle image loading delays — for best results, ensure image dimensions are known or use loading="lazy".
  • You can wrap the grid in a container with custom margins or padding for layout spacing.

🧰 Development

# Clone the repo
git clone https://github.com/Orestespp/solid-masonry-grid.git
cd solid-masonry-grid

# Install dependencies
npm install

# Build library
npm run build

📜 License

MIT © 2025 Orestes Pérez


💬 Feedback

Have suggestions or issues? Open an issue or submit a pull request.


Made with ❤️ using SolidJS