Components / Layout and type
ImageList
Grid of photos: products, a business's gallery, rewards.
import { ImageList } from "@stylhero/ui";
Example
Code
import { ImageList } from "@stylhero/ui";
const photos = ["1500530855697-b586d89ba3ee", "1470071459604-3b5ec3a7fe05", "1441974231531-c6227db76b6e", "1501785888041-af3ef285b470"];
const photo = (id: string) => `https://images.unsplash.com/photo-${id}?w=400&h=300&fit=crop&auto=format`;
function ImageListExample() {
return (
<ImageList columns={2} rowHeight={140} gap={2}
items={photos.map((id, i) => ({ src: photo(id), alt: `Landscape ${i + 1}`, title: `Landscape ${i + 1}` }))} />
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items required |
ImageListItem[] |
- | |
columns |
number |
3 |
|
gap |
Space |
2 |
|
rowHeight |
number |
180 |
Row height in px for standard and quilted. |
titlePosition |
"overlay" | "below" |
"overlay" |
Where the title sits: over the image or under it. |
variant |
"standard" | "quilted" | "masonry" |
"standard" |
"masonry" keeps each image's own height. "quilted" uses cols/rows per item. |
Also takes every <ul> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Types
type ImageListItem = {
src: string;
alt: string;
title?: ReactNode;
subtitle?: ReactNode;
/** Top-right action on the title bar, e.g. a favorite IconButton. */
action?: ReactNode;
/** Quilted layout: how many columns/rows this tile spans. */
cols?: number;
rows?: number;
};
type Space = 0 | 1 | 2 | 3 | 4 | 6 | 8 | 12;
Generated from src/components/ImageList.tsx. Something wrong or missing? Open an issue.