Lightbox

Use Lightbox when an image needs an inspectable full-size view. It expands from the thumbnail and returns to that same origin when dismissed.

Preview

Reduce motion:Off
Tune:Off
Inspect

Installation

Basic usage

TypeScript
project-image.tsx

Examples

Use controlled open state when the selected image is managed by a gallery. Add a caption when it provides information that is not visible in the image itself.

Usage

API

PropertyTypeDefaultDescription
srcstringrequiredThe image URL shown in both the thumbnail and expanded preview.
altstringrequiredAccessible alternative text for the image.
captionstringundefinedOptional caption displayed beneath the expanded image.
openbooleanundefinedControlled open state.
defaultOpenbooleanfalseInitial open state for uncontrolled usage.
onOpenChange(open: boolean) => voidundefinedCalled whenever the expanded preview opens or closes.
classNamestringundefinedAdditional CSS classes for the thumbnail trigger.
imageClassNamestringundefinedAdditional CSS classes for the thumbnail image.
previewClassNamestringundefinedAdditional CSS classes for the expanded image.
backdropClassNamestringundefinedAdditional CSS classes for the modal backdrop.

Accessibility

Lightbox manages focus, Escape dismissal, and scroll locking through Base UI. Always provide useful alternative text for the image.

Styling

Use the thumbnail, preview, and backdrop class options to match the gallery. Reduced-motion preferences use a cross-fade.

Contact

Found a bug or need help using this component? Open an issue on GitHub.

License & Usage

Sona UI is available under the MIT license. You may use, modify, and distribute this component in personal and commercial projects.

Was this page helpful?

Your response helps us improve component docs.