ImageZoom
Click-to-zoom lightbox image powered by medium-zoom, with a theme-aware backdrop.
The ImageZoom component from @publier/primitives wraps an image in a click-to-zoom lightbox. Behind the scenes it uses medium-zoom, attached on the client only, with a backdrop that uses the current theme’s background color.
Usage
import { ImageZoom } from '@publier/primitives';
<ImageZoom src="/screenshots/dashboard.png" alt="Publier dashboard overview" width={1280} height={720}/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | required | Image source URL. |
alt | string | required | Alt text for accessibility. |
width | number | undefined | Optional intrinsic width. |
height | number | undefined | Optional intrinsic height. |
class | string | undefined | Extra CSS class appended to the <img>. The class publier-image-zoom is always applied. |
Behaviour
- Renders a plain
<img>(withloading="lazy"anddecoding="async") so it degrades gracefully without JavaScript. - The lightbox uses a 24 px margin and a backdrop of
--color-base-100at 92% opacity. - The lightbox tears down cleanly when the page unmounts.
Usage in .astro and MDX
Drop <ImageZoom> straight into MDX or .astro — no client directive required. The image still renders without JavaScript; click-to-zoom kicks in once the page is interactive.