Skip to content
Skip to Content
DocsMasonry Grid
Masonry Grid

Masonry Grid

A responsive masonry-style image grid with hover animations and lightbox support.

Component preview

Install using CLI

npx shadcn@latest add "https://www.obsidianui.dev/r/masonry-grid.json"

Install Manually

1

Install dependencies

npm install motion clsx tailwind-merge
2

Add util file

Create a file lib/utils.ts:

import { ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
3

Copy the source code

Copy the code into components/block/masonry-grid.tsx

Usage

Code
import { MasonryGrid } from "@/components/block/masonry-grid"
export function Demo() {
return (
<MasonryGrid items={[{ image: "/image1.jpg", title: "Mountains", description: "A view from the summit" }]} />
)
}

Props

PropTypeDefaultDescription
items{ image: string; title: string; description: string }[]RequiredImages with their title and description
columnsnumberResponsive: 1–4Optional fixed number of columns
Last updated on