Image Zoom
A thumbnail that opens its full-size source in a dialog, with a caption and the focus behaviour a dialog owes its trigger.
The trigger is a real button and the large image opens in a dialog, so Escape closes it, the focus stays inside it and returns to the trigger when it closes. `sizes`, `widths` and `transform` apply to the trigger image, so a gallery preview stays responsive; `thumbnailSrc` keeps the trigger light while the dialog requests the full image at 100vw by default.
Preview
Installation
Add the item with the shadcn CLI, or copy the source manually.
pnpm dlx shadcn@latest add litingyes/blocove/image-zoomRequires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.
Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/image-zoom
API Reference
Props accepted by the exported components.
ImageZoom
A thumbnail that opens the full-size source in a dialog. The dialog owns the focus behaviour; the item owns the composition.
| Prop | Type | Default |
|---|---|---|
src | string | Required |
alt | string | Required |
thumbnailSrc | string | src |
caption | ReactNode | - |
aspectRatio | number | string | - |
width | number | - |
height | number | - |
priority | boolean | false |
sizes | string | '100vw' in the dialog |
widths | readonly number[] | - |
transform | (src, width) => string | Identity |
placeholder | string | - |
zoomLabel | string | Zoom image: <alt> |
triggerClassName | string | - |
className | string | - |