Open Source

Masonry grids,
blazingly fast.

Zero-dependency, virtualized masonry layouts for vanilla JS and React. Render 10,000+ items at 60fps with automatic column balancing.

View on npm → Live Demo → Documentation
npm install smart-masonry-grid

Why Choose Us

Everything you need.
Nothing you don't.

Built for performance, designed for simplicity.

Zero Dependencies

No bloat. Uses native ResizeObserver and IntersectionObserver. Your bundle stays light — under 5KB gzipped for the core.

🚀

Virtualization

Only renders what's visible. Binary search over sorted positions gives O(log n) lookups. Handle 10,000+ items without breaking a sweat.

📱

Responsive Columns

Auto-fit, fixed count, or breakpoint-based. Named breakpoints (sm/md/lg/xl) or custom pixel values. Columns adapt instantly on resize.

🎨

Entry Animations

Smooth slide-up-and-fade entrance for new items. Configurable duration, easing, and offset. Enable with a single prop.

⚙️

Dual API

Vanilla JS MasonryGrid class for any framework. React components for the React ecosystem. Same engine, two interfaces.

🌐

SSR Compatible

CSS columns fallback for server-rendered HTML. Hydrates seamlessly on the client. No flash of unstyled content.

0
Dependencies
0
Items at 60fps
0
Gzipped Core
0
TypeScript

The Difference

Why smart-masonry-grid?

Most masonry libraries are abandoned, React-only, or missing critical features.

Feature smart-masonry-grid masonry-layout react-masonry-css masonic @mui/lab
Zero dependencies
Virtualization (10K+ items)
SSR / Next.js support Partial Buggy
Vanilla JS + React Vanilla only React only React only React only
Built-in animations
Built-in infinite scroll
TypeScript (built-in) Partial
Responsive breakpoints 4 modes Basic Basic
Actively maintained Barely ✗ (4yr+) Partial

No other library combines zero-dependency virtualization, SSR support, and multi-framework support in one package.

Three lines to a
beautiful grid.

Import, wrap your items, done. Automatic measurement, positioning, and resize handling. No configuration needed for common use cases.

Auto column detection
Dynamic item height support
Built-in infinite scroll
Animate with one prop
App.tsx
import { Masonry } from 'smart-masonry-grid/react';

function Gallery({ photos }) {
  return (
    <Masonry
      columns={{ sm: 2, md: 3, lg: 4 }}
      gap={16}
      animate
    >
      {photos.map((photo) => (
        <img
          key={photo.id}
          src={photo.src}
          alt={photo.alt}
        />
      ))}
    </Masonry>
  );
}
Virtual.tsx
// Render 10,000 items — only visible ones in the DOM

<VirtualMasonry
  totalItems={10_000}
  renderItem={(index) => <Card index={index} />}
  height={600}
  columns={4}
  gap={16}
  animate
/>

Thousands of items.
Zero lag.

VirtualMasonry only renders items visible in the viewport plus a configurable overscan buffer. Binary search keeps lookups at O(log n).

O(log n) visible range lookup
Configurable overscan buffer
Lazy height measurement
Placeholder support

See It Live

Don't take our word for it.

Interactive demo with real Unsplash photos. Adjust columns, gap, and animations in real-time.

smart-masonry-grid-demo.vercel.app

Ready to build
something beautiful?

Get started in seconds. Zero config required.

npm install smart-masonry-grid