YuhuanStudioYunUIDocs
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<ImageLightbox
5 src={imageUrl}
6 alt="Generated image"
7 isOpen={open}
8 onClose={() => setOpen(false)}
9/>

Props

PropTypeDefaultDescription
altstring
childrenReactNodeCustom 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
srcstringImage URL to view. Omit when providing custom `children` (e.g. an SVG).

On this page