Gallery, masonry


Install
npx shadcn add @klarhimmel/gallery-masonryDetailsAbout, usage, props and more
Images in balanced columns with mixed frame shapes (wide, square, tall) and a caption under each. Use when the pictures are not all the same crop.
Import
Import
- gallery/masonry
- About
- Images in balanced columns with mixed frame shapes (wide, square, tall) and a caption under each. Use when the pictures are not all the same crop. Empty caption hides the line.
- Category
- A grid of images with captions. New project? Set it up once: /get-started/installation.
Notes
When to use it
Images in balanced columns where each frame can be wide, square or tall, with a caption below. It suits photos that were not shot to one crop; gallery-grid is tidier when they are all the same.
Writing for it
- Set shape for each item to wide (4 to 3), square or tall (3 to 4). Alternate them, because a run of the same shape gives you a plain grid. - Choose columns '2' or '3' for the widest container. Narrower containers use fewer on their own. - Add at least two items, up to twelve. Captions of up to 120 characters count in the height balancing, so empty ones change where columns break.
Watch out for
Column breaks are computed from the shapes and whether a caption exists, so reordering items or clearing a caption can move pictures between columns. Reading order runs down each column, not across rows.
Usage
The block in a page, with its default content (long lists shortened). Every prop is in the table below.
Props
The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.
| Prop | Type | Default | Description |
|---|---|---|---|
eyebrow | string | 'Name the topic' | Text, up to 60 characters. |
title | string | 'Invite them to look around the place' | Text, up to 120 characters. |
description | string | 'Say in one line how the pictures we…' | Text, up to 300 characters. |
columns | '2' | '3' | '3' | One of '2', '3'. |
items | { shape, media, caption }[] | 8 items | List of 2 to 12. Each item: shape ('wide' | 'square' | 'tall'), media, caption. |
headingLevel | '1' | '2' | - | One of '1', '2'. Optional; empty is not rendered. |