Skip to content

MasonryGrid

XS · 350B gzip budget

A zero-JS masonry layout via CSS columns.

Category
Data display
Budget
xs, static display primitive
External runtime
React / React DOM only
axe fixtureSSR rendersource scanbundle budget

Preview

Live fixture
Preview locale
Card A
Card B

Try the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.

Install

npx shadcn@latest add https://gear5-ui.vercel.app/r/masonry-grid.json

Copies the source into your project. Pulls in 1 shared registry item: cn.

New here? Set up Tailwind and import aliases first →

Source & props

Edit on GitHub ↗

Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.

import { cn } from "../lib/cn";

export interface MasonryGridProps {
  children: React.ReactNode;
  columns?: number;
  className?: string;
}

/**
 * CSS columns, not a JavaScript layout engine: this reflows correctly on
 * resize and under RTL for free (browsers already fill multi-column layouts
 * start-to-end, not literally left-to-right), and adds no runtime cost whatsoever.
 */
export function MasonryGrid({ children, columns = 3, className }: MasonryGridProps) {
  return (
    <div
      className={cn("gap-4 [&>*]:mb-4 [&>*]:break-inside-avoid", className)}
      style={{ columnCount: columns, columnGap: "1rem" }}
    >
      {children}
    </div>
  );
}

What CI checks

Quality contract
  • Bundled, minified and gzipped against its tier budget
  • Audited by axe in the state previewed above
  • Rendered through react-dom/server with no browser globals
  • Scanned for network calls, dangerous sinks, and unguarded animation