Lightbox
A UI SDK Dialog that shows one image of a set: previous and next (buttons and arrow keys), a counter, the caption, an open-original link and fit or actual size. Dark variants follow the theme with no flash; agents get next, previous and goTo.
Example
lightbox-demo.tsxCopy code
Installation
Copy code
npm packages
lucide-reactUsage
ImportCopy code
API reference
ThemedImage
| Prop | Type | Default |
|---|---|---|
srcrequired | string | – |
srcDarkShown instead of `src` while the page is dark. Both are rendered and CSS picks one, so nothing flashes. | string | – |
Also takes ImgHTMLAttributes except src.
Lightbox
| Prop | Type | Default |
|---|---|---|
itemsrequired | readonly LightboxItem[] | – |
index | number | – |
defaultIndex | number | 0 |
onIndexChange | IndexChange | – |
open | boolean | – |
defaultOpen | boolean | – |
onOpenChange | DialogProps["onOpenChange"] | – |
controller | DialogProps["controller"] | – |
finalFocusWhere focus goes on close; by default the trigger, or what was focused before it opened. | ComponentProps<typeof DialogContent>["finalFocus"] | – |
labels | Partial<LightboxLabels> | – |
className | string | – |
childrenRendered inside the dialog root, like a `DialogTrigger`. | ReactNode | – |
Other exports
lightboxlightboxLabelstype LightboxIndexChangeReasontype LightboxOptionstype ThemedImagePropstype LightboxItemtype LightboxLabelstype LightboxPropsAccessibility
- Arrow keys move between images with a counter; focus returns to what opened it.
- Sized in % of the top layer, never viewport units.
Agent actions
Agents see Image viewer with next, previous and goTo(index).
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.