Ballmac UI home

Masonry Grid

A gap-free multi-column layout for tiles of different heights, built on CSS columns so it never shifts on load, with responsive column counts and optional reveal.

Morning light
Workshop
Harbor
Studio wall
Field notes
Sketch
Terrace
Market
Ceramics

Installation

$ pnpm dlx shadcn@latest add @ballmac/masonry-grid

Usage

import { MasonryGrid, MasonryItem } from "@/components/ballmac/masonry-grid"

The full example is in the Code tab above.

Examples

Notes

Ship small

Release the smallest useful change, then learn from it.

Write it down

A short note today saves a long meeting next month. Keep the feedback loop short so you notice problems early.

Name things well

Good names make code, files and plans easier to follow.

Review early

Share drafts while they are still easy to change. Keep the feedback loop short so you notice problems early.

Measure one thing

Pick a single number that tells you if it worked.

API reference

PropTypeDefault
columns

Number of columns, or a count per breakpoint: `{ base: 1, sm: 2, lg: 4 }`.

MasonryColumns{ base: 1, sm: 2, lg: 3 }
gap

Space between items.

keyof typeof GAPS"md"
reveal

Fade items up as they scroll into view. Off under reduced motion.

booleanfalse

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Tab orderFollows DOM order, which matches the visual column flow
Reduced motionReveal animation is skipped

Quality scorecard

6/6

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 2 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    No endless animation to begin with.

  • Passed: Right to left

    Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Not applicable: Keyboard

    Static content: nothing to focus.

  • Not applicable: Loading, empty and error

    Does not show data or take submissions.

  • Passed: Automated tests

    Covered by masonry-grid.test.tsx.

  • For information: Footprint

    1.4 KB of source (gzip) in 1 file. Installs motion.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Use with AI

<MasonryGrid columns={{base:2, lg:4}} gap reveal><MasonryItem/>…</MasonryGrid>. DOM order is reading order: down the first column, then the next. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Masonry Grid (@ballmac/masonry-grid) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Galleries, portfolios and boards
  • Testimonials or notes of uneven length

Not for

  • Rows that must line up across columns; use CSS grid
  • Sortable boards; use kanban-board

Registry JSON: https://ui.ballmac.com/r/masonry-grid.json

Credits

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.