ProductGallery
A product's pictures.
View code
<ProductGallery
images={poster.images.map((image) => ({ id: image.id, alt: image.alt, href: `?image=${image.id}`, media: <img src={image.src} alt="" /> }))}
current={url.searchParams.get("image") ?? "front"}
lightbox="poster-photos"
labels={{ zoom: "Zoom", image: "Image {n} of {total}" }}
/>
<Lightbox id="poster-photos" label="Photos of Dune at dusk" photos={poster.images} />Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { ProductGallery } from "@sdxc/ui/commerce";Renders the gallery. Wide, the stage sits beside a rail of thumbnail links marked
aria-current at the current picture; on a phone, every picture sits in a scroll-snap strip
with a dot per picture, and the rail hides.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
images | Image[] | Yes | |
current | string | Yes | The id of the picture on the stage; the first picture when it matches none. |
background | string | No | The colour behind every picture. |
ratio | string | No | Every picture's aspect ratio. @default "4 / 5" |
lightbox | string | No | The id of a root Lightbox dialog the zoom button opens at the current picture. |
labels | Labels | Yes |
Also accepts everything in Omit<TagProps<"div">, "children">.