# Product Gallery

> A product page gallery: a scroll-snap stage that phones swipe with native momentum, hover magnification under the mouse, a thumbnail rail on the left or a strip below that keeps the active one in view, dots when it's narrow, and a fullscreen viewer with the same swipes, arrows and keys. A controlled index keeps it in step with a variant picker.

- Slug: `product-gallery`
- Category: [Commerce](https://www.assembli.design/category/commerce.md)
- Type: component
- Tags: gallery, product, ecommerce, thumbnails, zoom, carousel, fullscreen, swipe
- npm dependencies: @base-ui/react, lucide-react
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/product-gallery
- Page: https://www.assembli.design/components/product-gallery

![Product Gallery preview](https://www.assembli.design/thumbnails/product-gallery-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `images` (required) | `GalleryImage[]` |  |  |
| `index` | `number` |  | The image shown, for syncing with a variant picker. |
| `defaultIndex` | `number` | `0` |  |
| `onIndexChange` | `(index: number) => void` |  |  |
| `thumbnails` | `"left" \| "bottom" \| "none"` | `"left"` | Where the thumbnails sit once the gallery is wide enough. Narrow galleries always use dots. |
| `aspect` | `string` | `"4 / 5"` | Aspect ratio of the stage, as CSS: `"4 / 5"`, `"1"`. |
| `zoom` | `boolean` | `true` | Magnify under the mouse on hover. |
| `badge` | `React.ReactNode` |  | A label laid over the top-left corner, e.g. "New" or "−20%". |
| `container` | `HTMLElement \| React.RefObject<HTMLElement \| null> \| null` |  | Mount the fullscreen viewer inside this element instead of `<body>`. |
| `aria-label` | `string` |  |  |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/product-gallery/product-gallery.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/product-gallery
```

Registry item JSON: https://www.assembli.design/r/product-gallery.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
