Feedback
Lightbox
A full-screen image viewer on a native modal dialog.
<script>
import { Lightbox } from "@codeatlasdev/ui";
let open = $state(false);
</script>
<button onclick={() => (open = true)}>View photo</button>
<Lightbox bind:open src={url} alt="Photo sent by Maria" />
The image is contained in the viewport and respects the device safe areas. Escape, the close button and a click on the backdrop close it. Because it is a native modal <dialog>, the page behind is inert, focus returns to the trigger and scrolling is locked while it is open. alt is required.
Open from a button
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Bindable open state. |
src | string | – | Image URL. Required. |
alt | string | – | Image description. Required. |
onclose | () => void | – | Called after the viewer closes. |