Content
Image Lightbox
A full-screen image viewer with zoom, rotate, download and keyboard shortcuts, rendered into a portal.
A controlled, full-screen image viewer rendered into a portal on document.body. It supports zoom, rotate, download and keyboard shortcuts (Esc to close, + / - to zoom, R to rotate). It's the viewer that ContentImage opens on click, but you can drive it yourself for any image: hold the open state and pass isOpen / onClose.
Import
tsx
1import { ImageLightbox } from "@yuhuanowo/yunui/content";Example
ImageLightbox
Usage
tsx
1const [open, setOpen] = useState(false);2 3<button onClick={() => setOpen(true)}>View</button>4<ImageLightbox5 src={imageUrl}6 alt="Generated image"7 isOpen={open}8 onClose={() => setOpen(false)}9/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| alt | string | — | |
| children | ReactNode | — | Custom zoomable content instead of an `<img src>` — e.g. an inline SVG diagram. Download is only offered when `src` is set. |
| isOpen* | boolean | — | |
| onClose* | () => void | — | |
| src | string | — | Image URL to view. Omit when providing custom `children` (e.g. an SVG). |