Component reference
Lightbox
Open a gallery at its selected image.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import { Button, Lightbox, type PimoluLightboxImage } from "@pimolu/react";
import { useState } from "react";
const gallery: PimoluLightboxImage[] = [
{
src: "/images/pimolu-studio.webp",
alt: "Pimolu Studio product illustration",
caption: "Pimolu Studio — one design language for web and native.",
thumbnail: "/images/pimolu-studio.webp",
},
{
src: "/images/pimolu-avatar.svg",
alt: "Pimolu p emblem on an indigo avatar",
caption: "Jean Dupont · Design engineer",
thumbnail: "/images/pimolu-avatar.svg",
},
{
src: "/images/pimolu-studio.webp",
alt: "Pimolu Studio illustration, detail view",
caption: "Every preset shares the same component API.",
thumbnail: "/images/pimolu-studio.webp",
},
];
export function DemoExample() {
const [basicOpen, setBasicOpen] = useState(false);
return (
<div className="grid gap-5 min-w-0">
<Button onClick={() => setBasicOpen(true)}>Open gallery</Button>
<span className="text-sm text-muted leading-relaxed">Three images · thumbnails · no loop</span>
<Lightbox
images={gallery}
open={basicOpen}
onOpenChange={setBasicOpen}
showThumbnails
/>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Single product image
A focused image viewer with a caption and explicit dismissal.
Controlled index
The parent owns both the open state and the active image. Opening from a card sets the index first, so the viewer starts on the chosen image.
Localized labels
Counter, thumbnail names and every control accept localized copy.
Usage
Use useful alternative text and preserve the selected index in controlled workflows.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluLightboxImage
Type source| Name | Type | Default | Description |
|---|---|---|---|
srcRequired | string | — | Full-size image URL. |
altRequired | string | — | Alternative text of the image. Required on purpose. |
caption | ReactNode | — | Caption rendered under the image. |
thumbnail | string | undefined | `src` | Optional thumbnail URL; defaults to `src`. |
srcRequiredstringNo default extracted.
Full-size image URL.
altRequiredstringNo default extracted.
Alternative text of the image. Required on purpose.
captionReactNodeNo default extracted.
Caption rendered under the image.
thumbnailstring | undefinedDefault: `src`
Optional thumbnail URL; defaults to `src`.
PimoluLightboxLabels
Type source| Name | Type | Default | Description |
|---|---|---|---|
dialog | string | undefined | "Image viewer" | Accessible name of the modal. Defaults to "Image viewer". |
close | string | undefined | "Close" | Defaults to "Close". |
previous | string | undefined | "Previous image" | Defaults to "Previous image". |
next | string | undefined | "Next image" | Defaults to "Next image". |
thumbnails | string | undefined | "Choose an image" | Defaults to "Choose an image". |
counter | ((position: number, total: number) => string) | undefined | `${position} / ${total}` | Position readout. Defaults to `${position} / ${total}`. |
goTo | ((position: number, total: number) => string) | undefined | — | Accessible name of a thumbnail. |
dialogstring | undefinedDefault: "Image viewer"
Accessible name of the modal. Defaults to "Image viewer".
closestring | undefinedDefault: "Close"
Defaults to "Close".
previousstring | undefinedDefault: "Previous image"
Defaults to "Previous image".
nextstring | undefinedDefault: "Next image"
Defaults to "Next image".
thumbnailsstring | undefinedDefault: "Choose an image"
Defaults to "Choose an image".
counter((position: number, total: number) => string) | undefinedDefault: `${position} / ${total}`
Position readout. Defaults to `${position} / ${total}`.
goTo((position: number, total: number) => string) | undefinedNo default extracted.
Accessible name of a thumbnail.
PimoluLightboxProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
imagesRequired | PimoluLightboxImage[] | — | Gallery items. An empty array renders nothing. |
open | boolean | undefined | — | Controlled open state. Omit to let the component own it. |
defaultOpen | boolean | undefined | false | Initial open state when uncontrolled. Defaults to false. |
onOpenChange | ((open: boolean) => void) | undefined | — | Called when the lightbox asks to open or close. |
index | number | undefined | — | Controlled current index. Omit to let the component own it. |
initialIndex | number | undefined | 0 | Initial index when uncontrolled. Defaults to 0. |
onIndexChange | ((index: number) => void) | undefined | — | Called whenever the active image changes. |
loop | boolean | undefined | false | Wrap around at both ends. Defaults to false. |
closeOnOverlayClick | boolean | undefined | true | Close when the overlay is pressed. Defaults to true. |
closeOnEscape | boolean | undefined | true | Close on Escape. Defaults to true. |
showThumbnails | boolean | undefined | false | Render a thumbnail strip under the stage. Defaults to false. |
labels | PimoluLightboxLabels | undefined | — | Localizable labels. |
aria-label | string | undefined | — | Accessible name of the modal. Overrides `labels.dialog`. |
className | string | undefined | — | Class applied to the modal panel. |
imagesRequiredPimoluLightboxImage[]No default extracted.
Gallery items. An empty array renders nothing.
openboolean | undefinedNo default extracted.
Controlled open state. Omit to let the component own it.
defaultOpenboolean | undefinedDefault: false
Initial open state when uncontrolled. Defaults to false.
onOpenChange((open: boolean) => void) | undefinedNo default extracted.
Called when the lightbox asks to open or close.
indexnumber | undefinedNo default extracted.
Controlled current index. Omit to let the component own it.
initialIndexnumber | undefinedDefault: 0
Initial index when uncontrolled. Defaults to 0.
onIndexChange((index: number) => void) | undefinedNo default extracted.
Called whenever the active image changes.
loopboolean | undefinedDefault: false
Wrap around at both ends. Defaults to false.
closeOnOverlayClickboolean | undefinedDefault: true
Close when the overlay is pressed. Defaults to true.
closeOnEscapeboolean | undefinedDefault: true
Close on Escape. Defaults to true.
showThumbnailsboolean | undefinedDefault: false
Render a thumbnail strip under the stage. Defaults to false.
labelsPimoluLightboxLabels | undefinedNo default extracted.
Localizable labels.
aria-labelstring | undefinedNo default extracted.
Accessible name of the modal. Overrides `labels.dialog`.
classNamestring | undefinedNo default extracted.
Class applied to the modal panel.
Accessibility
- Verify Escape, previous/next controls, modal focus containment and return to the originating thumbnail.