Masonry

Items of uneven heights in columns, with no holes between them.

Moodboard
Typography
Palette
Wireframes
Motion
Handoff

Installation#

pnpm dlx shadcn@latest add @balick/masonry

Or pass the full URL: https://ui.balick.me/r/masonry.json

Usage#

import { Masonry } from "@/components/ui/masonry"

export function Gallery({ photos }: { photos: { src: string; alt: string }[] }) {
  return (
    <Masonry>
      {photos.map((photo) => (
        <img key={photo.src} src={photo.src} alt={photo.alt} className="w-full rounded-xl" />
      ))}
    </Masonry>
  )
}

Props#

PropTypeDefault
gap

Space between items, as a CSS length.

string"1rem"
className

One, two, then three columns as the container widens. Set your own with columns-*.

string—