# Lightbox

> A full-screen photo viewer for a gallery, as a native `<dialog>` a trigger opens through Invoker Commands.

```ts
import { Lightbox } from "@sdxc/ui";
```

Renders the viewer: a full-screen dark `<dialog>` with a close button, one slide per photo
(contained, with "n / N" and its caption) and step links between neighbours. Opened from a
Lightbox.Trigger; Escape and the close button dismiss it.

## Examples

```tsx
<Lightbox.Trigger lightbox="cabin-photos" index={2}><img src={thumb} alt="" /></Lightbox.Trigger>
<Lightbox id="cabin-photos" label="Photos of Fern Cabin" photos={photos} />
```

```tsx
<Lightbox id="cabin-photos" label="Photos" photos={photos} initial={Number(url.searchParams.get("photo")) - 1} />
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `id` | `string` | Targeted by each trigger's `commandfor`, and the prefix of every photo's own id. |
| `label` | `string` | The gallery's name, such as "Photos of Fern Cabin", read when the viewer opens. |
| `photos` | `Photo[]` |  |
| `initial?` | `number` | Renders the viewer already open at this zero-based photo, for a page whose address names one (`?photo=3`). Without script it is a non-modal dialog covering the page; the island reopens it as a modal. |
| `labels?` | `Partial<Labels>` |  |

Also accepts everything in `Omit<TagProps<"dialog">, "children" | "open">`.


### Lightbox.Trigger

Renders a button that opens the viewer named by `lightbox` as a modal, at photo `index` once the island has loaded.

| Prop | Type | Description |
| --- | --- | --- |
| `lightbox` | `string` | `id` of the Lightbox this opens. |
| `index?` | `number` | Zero-based photo the viewer opens at once the island has loaded. |

Also accepts everything in `Omit<TagProps<"button">, "commandfor" | "command">`.

