GalleryGrid
GalleryGrid — a wall of images, justified (rows that fill the width, as `justifyRows` packs them) or a plain equal-column grid, optionally grouped under sticky headers. Tiles are plain `<div>`s until `onItemClick` or `onSelectionChange` is given; then each becomes a `<button>` named by the item's `alt` (or caption, or "Image N"), so the gallery is keyboard- and screen-reader- navigable without a wrapper per tile. A selected tile shows a ring and `aria-pressed`. `renderItem` swaps the `<img>` for anything while keeping the layout and the click; `renderBadges` overlays the default tile. Default tiles lazy-load into a `bg-muted` box already sized from the item's `width`/`height` (4:3 when unknown), so rows do not reflow as images arrive.
packages/ui/src/components/patterns/gallery-grid.tsx
@marktiderman/genesis-ui/patternsimport { GalleryGrid } from "@marktiderman/genesis-ui/patterns";react-docgen-typescript.GalleryGrid
GalleryGrid — a wall of images, justified (rows that fill the width, as `justifyRows` packs them) or a plain equal-column grid, optionally grouped under sticky headers. Tiles are plain `<div>`s until `onItemClick` or `onSelectionChange` is given; then each becomes a `<button>` named by the item's `alt` (or caption, or "Image N"), so the gallery is keyboard- and screen-reader- navigable without a wrapper per tile. A selected tile shows a ring and `aria-pressed`. `renderItem` swaps the `<img>` for anything while keeping the layout and the click; `renderBadges` overlays the default tile. Default tiles lazy-load into a `bg-muted` box already sized from the item's `width`/`height` (4:3 when unknown), so rows do not reflow as images arrive.
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | GalleryItem[] | — | |
| aspectRatio | GalleryTileAspect | 1 | `layout="grid"` only: each tile's shape, a ratio or `"item"` for the item's own. Default 1 (square), as on native. |
| className | string | — | |
| columns | number | GALLERY_DEFAULTS.columns | Column count for `layout="grid"`. Default 3. |
| gap | number | GALLERY_DEFAULTS.gap | Space between tiles in px. Default 4. |
| getGroup | ((item: GalleryItem) => string) | — | @deprecated Use `groupBy`. |
| groupBy | ((item: GalleryItem) => string) | — | Groups items by the returned key, in order of first appearance; each group is laid out on its own under a sticky header showing the key (a view's `groupBy`, for an array). |
| layout | enum | justified | `justified` (default): rows of a target height, each scaled to fill the width, Flickr-style. `grid`: a fixed number of equal columns. |
| loadMore | (() => void) | — | Called once when the sentinel after the last row scrolls into view, and armed again whenever `items.length` changes — the hook for "load more" (the same name as ResourceView's). |
| onItemClick | ((item: GalleryItem, index: number) => void) | — | Makes every tile a button and reports which was activated. |
| onNearEnd | (() => void) | — | @deprecated Use `loadMore`. |
| onSelectionChange | ((ids: string[], detail: GallerySelectionDetail) => void) | — | Turns tile clicks into selection: a click toggles the item, shift-click selects the range from the last toggled tile. Called with the whole new selection and the tile that caused it. While set, `onItemClick` is not called for clicks (open the item from an action instead). |
| renderBadges | ((item: GalleryItem, index: number) => ReactNode) | — | Overlaid top-left of the default tile (ignored when `renderItem` takes over). |
| renderItem | ((item: GalleryItem, index: number) => ReactNode) | — | Replaces the default `<img>` tile. The wrapper still sizes and clicks. |
| rowHeight | number | GALLERY_DEFAULTS.rowHeight | Target row height in px for `layout="justified"`. Default 180. |
| selected | string[] | — | Ids of the selected items. Selection is on when `onSelectionChange` is given. |