Skip to content
Klarhimmel UI

Gallery, grid

Gallery, grid previewGallery, grid preview

Install

npx shadcn add @klarhimmel/gallery-grid
DetailsAbout, usage, props and more

A grid of images with captions under a heading, filled row by row. columns "2" keeps pairs side by side, such as before and after.

Import

Import

import Block from '@/components/klarhimmel/blocks/gallery-grid';
Also called
  • gallery/grid
About
A grid of images with captions under a heading, filled row by row. columns "2" keeps pairs side by side, such as before and after. Give items a price and a note to show things for sale.
Category
A grid of images with captions. New project? Set it up once: /get-started/installation.

Notes

When to use it

Even grid of equally cropped images with captions under a heading. Use it for a set of similar frames; when the pictures vary in shape, gallery-masonry avoids cropping them all to one ratio.

Writing for it

- You can add one to twelve items. Six or nine fill the three-column layout without a ragged last row. - Captions are 120 characters. A few words naming the thing shown work better than a sentence repeating the alt text. - Use alt text to describe the picture and the caption to say why it is here, so the two do not duplicate each other.

Watch out for

Every image is forced to 4 by 3, which crops portrait photos. Captions are hidden when empty, so mix captioned and uncaptioned items and the rows will have different heights.

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 GalleryGrid from '@/components/klarhimmel/blocks/gallery-grid';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <GalleryGrid props={{
          "eyebrow": "Name the topic",
          "title": "Say what the pictures show",
          "description": "Say in one line what the pictures show and where they were taken.",
          "items": [
            {
              "media": {
                "src": "/pictures/photo-rest1.avif",
                "alt": "An empty dining room with long tables and pendant lamps"
              },
              "caption": "Name the subject"
            },
            {
              "media": {
                "src": "/pictures/photo-salon2.avif",
                "alt": "A salon interior in black and white with chairs and mirrors"
              },
              "caption": "Name the subject"
            },
            {
              "media": {
                "src": "/pictures/photo-spa1.avif",
                "alt": "A treatment room with a massage table by a window"
              },
              "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'Say what the pictures show'Text, up to 120 characters.
descriptionstring'Say in one line what the pictures s…'Text, up to 300 characters.
columns'2' | '3'-One of '2', '3'. Optional; empty is not rendered.
actionsLink[]-List of up to 2. Optional; empty is not rendered.
tilesboolean-Optional; empty is not rendered.
titleSize'heading' | 'display'-One of 'heading', 'display'. Optional; empty is not rendered.
items{ media, caption, price, note, href }[]6 itemsList of 1 to 24. Each item: media, caption, price (optional), note (optional), href (optional).
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.