Components / Interface
Image Lightbox
A thumbnail that opens the full image with zoom buttons, wheel zoom and drag to pan.
Installation
npx shadcn@latest add https://jiaweing.com/r/image-lightbox.jsonWith the @jiaweing namespace set up, use @jiaweing/image-lightbox in place of the URL.
Usage
tsx
import { ImageLightbox } from "@/components/image-lightbox";tsx
<ImageLightbox alt="The launch poster" src="/poster.png" />Props
ImageLightbox
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | - | The full image. |
| alt | string | - | Alt text, also the dialog title. |
| thumbnailSrc | string | - | A smaller image for the thumbnail. Defaults to src. |
| width / height | number | - | Intrinsic size, so the page does not shift. |
| caption | ReactNode | - | Shown under the full image. |
| maxZoom | number | 4 | Largest zoom, where 1 is the fitted size. |
| zoomStep | number | 0.25 | Zoom per button press or wheel tick. |
| labels | { zoomIn?, zoomOut?, reset?, close? } | - | Control labels, for other languages. |
| className | string | - | Classes for the thumbnail image. |
| triggerClassName | string | - | Classes for the thumbnail button. |
MIT licensed. Copy it, change it, ship it.