Gallery, grid
betaThree to twelve photos in a grid, the first one large; a photo opens in a dialog with its caption and arrows.
npx rasengan-ui add gallery-grid
From our kitchen
The room, the terrace and a few of the dishes people come back for.
- Use it
- Showing the place, the dishes or the work, when photos sell better than words.
- Avoid it
- Fewer than three good photos; product photos to buy from.
- Pairs with
- About, storyHours, week
Installation
It installs into components/blocks/gallery-grid/, with what it uses (Dialog, Button) and lib/blocks.ts.
Usage
Without content, the block shows its example. Pass your own, typed by the block's schema, from a content file (here, the example with one field changed):
The first photo is shown two by two. A photo opens in a Dialog, large, with its caption; the arrows and the arrow keys move to the others. Captions also show over the photo on hover and focus.
Content
| Field | Type | Limits | Guidance |
|---|---|---|---|
title | string | 2–48 chars | 'The place', 'From our kitchen'. |
sublineoptional | string | ≤ 160 chars | |
photos | object[] | 3–12 items | The first is shown large. Real photos of the place, the dishes, the team. |
photos[].src | string | A local path ('/images/terrace.jpg') or the project's asset URL. | |
photos[].alt | string | ≤ 140 chars | What the image shows, for people who cannot see it. Empty only if purely decorative. |
photos[].width | integer | ||
photos[].height | integer | ||
photos[].captionoptional | string | ≤ 80 chars | Shown under the photo when it is open. |
labels | object | The names of the buttons in the open photo, for screen readers. | |
labels.previous | string | 1–24 chars | 'Previous photo' |
labels.next | string | 1–24 chars | 'Next photo' |
Props
| Prop | Notes |
|---|---|
content | GalleryGridContent; the example when left out |
id | the section's id, for anchor links; "gallery" by default |
headingLevel | 1, 2 or 3: the heading's tag; 2 by default |
className | on the <section>, for spacing |
Accessibility
- Each photo is a button named by its
alt; the Dialog traps focus and closes with Escape. - The previous and next buttons are named by
labels.