Skip to content
Klarhimmel UI

Gallery, masonry

Gallery, masonry previewGallery, masonry preview

Install

npx shadcn add @klarhimmel/gallery-masonry
DetailsAbout, 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

import Block from '@/components/klarhimmel/blocks/gallery-masonry';
Also called
  • 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.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import GalleryMasonry from '@/components/klarhimmel/blocks/gallery-masonry';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <GalleryMasonry props={{
          "eyebrow": "Name the topic",
          "title": "Invite them to look around the place",
          "description": "Say in one line how the pictures were taken.",
          "columns": "3",
          "items": [
            {
              "shape": "square",
              "media": {
                "src": "/pictures/photo-wed1.avif",
                "alt": "A timber barn hall dressed with white fabric and tables"
              },
              "caption": "Name what this shows"
            },
            {
              "shape": "wide",
              "media": {
                "src": "/pictures/photo-wood3.avif",
                "alt": "A workbench with hand tools on the wall"
              },
              "caption": "Name the subject"
            },
            {
              "shape": "square",
              "media": {
                "src": "/pictures/photo-bakery1.avif",
                "alt": "A bakery counter with loaves and pastries behind glass"
              },
              "caption": "Name the subject"
            }
          ]
        }} />
      </BlockSurface>
    </Theme>
  );
}

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.

PropTypeDefaultDescription
eyebrowstring'Name the topic'Text, up to 60 characters.
titlestring'Invite them to look around the place'Text, up to 120 characters.
descriptionstring'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 itemsList of 2 to 12. Each item: shape ('wide' | 'square' | 'tall'), media, caption.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.