Use Lightbox when an image needs an inspectable full-size view. It expands from the thumbnail and returns to that same origin when dismissed.
Install
Basic usage
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.
API
| Property | Type | Default | Description |
|---|
src | string | required | The image URL shown in both the thumbnail and expanded preview. |
alt | string | required | Accessible alternative text for the image. |
caption | string | undefined | Optional caption displayed beneath the expanded image. |
open | boolean | undefined | Controlled open state. |
defaultOpen | boolean | false | Initial open state for uncontrolled usage. |
onOpenChange | (open: boolean) => void | undefined | Called whenever the expanded preview opens or closes. |
className | string | undefined | Additional CSS classes for the thumbnail trigger. |
imageClassName | string | undefined | Additional CSS classes for the thumbnail image. |
previewClassName | string | undefined | Additional CSS classes for the expanded image. |
backdropClassName | string | undefined | Additional 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.
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.