Lightbox
Lightbox — a full-screen image viewer over the page, built on `Dialog`. Prev/next buttons, ArrowLeft/ArrowRight and a horizontal swipe step through `items`; they stop at the ends (no wrap-around), and the button at an end is disabled so a keyboard user is not sent to a dead control. Escape closes, as every Dialog does. A "3 / 12" counter sits top-left with the optional `title`/`description`; `renderActions` fills the top-right beside Close; the caption (or `renderCaption`) sits under the stage, which shows the image `object-contain` or whatever `renderMedia` supplies. A picture with no `alt` is named by its position ("Image 3 of 12"), never left unnamed. Reaching an end moves focus to the other arrow, so the keyboard never lands on a disabled button. Controlled only: the consumer owns `open` and `index`, so the same state can drive a `GalleryGrid` highlight or a URL.
packages/ui/src/components/patterns/lightbox.tsx
@marktiderman/genesis-ui/patternsimport { Lightbox } from "@marktiderman/genesis-ui/patterns";react-docgen-typescript.Lightbox
Lightbox — a full-screen image viewer over the page, built on `Dialog`. Prev/next buttons, ArrowLeft/ArrowRight and a horizontal swipe step through `items`; they stop at the ends (no wrap-around), and the button at an end is disabled so a keyboard user is not sent to a dead control. Escape closes, as every Dialog does. A "3 / 12" counter sits top-left with the optional `title`/`description`; `renderActions` fills the top-right beside Close; the caption (or `renderCaption`) sits under the stage, which shows the image `object-contain` or whatever `renderMedia` supplies. A picture with no `alt` is named by its position ("Image 3 of 12"), never left unnamed. Reaching an end moves focus to the other arrow, so the keyboard never lands on a disabled button. Controlled only: the consumer owns `open` and `index`, so the same state can drive a `GalleryGrid` highlight or a URL.
| Prop | Type | Default | Description |
|---|---|---|---|
| index* | number | — | Index of the item on show. |
| items* | GalleryItem[] | — | |
| onIndexChange* | (index: number) => void | — | |
| onOpenChange* | (open: boolean) => void | — | |
| open* | boolean | — | |
| className | string | — | |
| description | ReactNode | — | Shown under the title in the top bar, muted. |
| labels | Partial<LightboxLabels> | — | |
| onKey | ((e: KeyboardEvent) => void) | — | Keydowns the lightbox did not handle itself (not the arrows, not Escape), filtered through `isAppShortcutTarget`: never fired when the event is already defaultPrevented, a ctrl/meta/alt modifier is held, or focus is in a field or a widget with its own keys. For "f to favourite"-style shortcuts. |
| renderActions | ((item: GalleryItem, index: number) => ReactNode) | — | Extra controls in the top-right, beside the close button. |
| renderCaption | ((item: GalleryItem, index: number) => ReactNode) | — | Replaces the default caption (the item's `caption`) under the image. |
| renderMedia | ((item: GalleryItem, index: number) => ReactNode) | — | Replaces the item's picture in the stage (a video, a before/after compare), per item, as on native. The stage keeps its definite height and the prev/next buttons sit over it. |
| title | string | — | Shown in the top bar; also becomes the dialog's accessible title. |