Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Lightbox

Open a gallery at its selected image.

Preview

Live preview

Changes apply to this preview only.

Three images · thumbnails · no loop

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

A focused image viewer with a caption and explicit dismissal.

Open preview

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.

Open preview

Counter, thumbnail names and every control accept localized copy.

Open preview

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
PimoluLightboxImage public API
NameTypeDefaultDescription
srcRequiredstring—Full-size image URL.
altRequiredstring—Alternative text of the image. Required on purpose.
captionReactNode—Caption rendered under the image.
thumbnailstring | undefined`src`Optional thumbnail URL; defaults to `src`.
srcRequired

string

No default extracted.

Full-size image URL.

altRequired

string

No default extracted.

Alternative text of the image. Required on purpose.

caption

ReactNode

No default extracted.

Caption rendered under the image.

thumbnail

string | undefined

Default: `src`

Optional thumbnail URL; defaults to `src`.

PimoluLightboxLabels

Type source
PimoluLightboxLabels public API
NameTypeDefaultDescription
dialogstring | undefined"Image viewer"Accessible name of the modal. Defaults to "Image viewer".
closestring | undefined"Close"Defaults to "Close".
previousstring | undefined"Previous image"Defaults to "Previous image".
nextstring | undefined"Next image"Defaults to "Next image".
thumbnailsstring | 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.
dialog

string | undefined

Default: "Image viewer"

Accessible name of the modal. Defaults to "Image viewer".

close

string | undefined

Default: "Close"

Defaults to "Close".

previous

string | undefined

Default: "Previous image"

Defaults to "Previous image".

next

string | undefined

Default: "Next image"

Defaults to "Next image".

thumbnails

string | undefined

Default: "Choose an image"

Defaults to "Choose an image".

counter

((position: number, total: number) => string) | undefined

Default: `${position} / ${total}`

Position readout. Defaults to `${position} / ${total}`.

goTo

((position: number, total: number) => string) | undefined

No default extracted.

Accessible name of a thumbnail.

PimoluLightboxProps

Type source
PimoluLightboxProps public API
NameTypeDefaultDescription
imagesRequiredPimoluLightboxImage[]—Gallery items. An empty array renders nothing.
openboolean | undefined—Controlled open state. Omit to let the component own it.
defaultOpenboolean | undefinedfalseInitial open state when uncontrolled. Defaults to false.
onOpenChange((open: boolean) => void) | undefined—Called when the lightbox asks to open or close.
indexnumber | undefined—Controlled current index. Omit to let the component own it.
initialIndexnumber | undefined0Initial index when uncontrolled. Defaults to 0.
onIndexChange((index: number) => void) | undefined—Called whenever the active image changes.
loopboolean | undefinedfalseWrap around at both ends. Defaults to false.
closeOnOverlayClickboolean | undefinedtrueClose when the overlay is pressed. Defaults to true.
closeOnEscapeboolean | undefinedtrueClose on Escape. Defaults to true.
showThumbnailsboolean | undefinedfalseRender a thumbnail strip under the stage. Defaults to false.
labelsPimoluLightboxLabels | undefined—Localizable labels.
aria-labelstring | undefined—Accessible name of the modal. Overrides `labels.dialog`.
classNamestring | undefined—Class applied to the modal panel.
imagesRequired

PimoluLightboxImage[]

No default extracted.

Gallery items. An empty array renders nothing.

open

boolean | undefined

No default extracted.

Controlled open state. Omit to let the component own it.

defaultOpen

boolean | undefined

Default: false

Initial open state when uncontrolled. Defaults to false.

onOpenChange

((open: boolean) => void) | undefined

No default extracted.

Called when the lightbox asks to open or close.

index

number | undefined

No default extracted.

Controlled current index. Omit to let the component own it.

initialIndex

number | undefined

Default: 0

Initial index when uncontrolled. Defaults to 0.

onIndexChange

((index: number) => void) | undefined

No default extracted.

Called whenever the active image changes.

loop

boolean | undefined

Default: false

Wrap around at both ends. Defaults to false.

closeOnOverlayClick

boolean | undefined

Default: true

Close when the overlay is pressed. Defaults to true.

closeOnEscape

boolean | undefined

Default: true

Close on Escape. Defaults to true.

showThumbnails

boolean | undefined

Default: false

Render a thumbnail strip under the stage. Defaults to false.

labels

PimoluLightboxLabels | undefined

No default extracted.

Localizable labels.

aria-label

string | undefined

No default extracted.

Accessible name of the modal. Overrides `labels.dialog`.

className

string | undefined

No default extracted.

Class applied to the modal panel.

Accessibility

  • Verify Escape, previous/next controls, modal focus containment and return to the originating thumbnail.
Read the accessibility guide →