SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

ProductGallery

A product's pictures.

View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
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.

PropTypeRequiredDescription
imagesImage[]Yes
currentstringYesThe id of the picture on the stage; the first picture when it matches none.
backgroundstringNoThe colour behind every picture.
ratiostringNoEvery picture's aspect ratio. @default "4 / 5"
lightboxstringNoThe id of a root Lightbox dialog the zoom button opens at the current picture.
labelsLabelsYes

Also accepts everything in Omit<TagProps<"div">, "children">.

@sdxc/ui

Can’t find it? Contact us