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.

UIimage-zoomView JSON

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-zoom

Requires 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.

PropTypeDefault
srcstringRequired
altstringRequired
thumbnailSrcstringsrc
captionReactNode-
aspectRationumber | string-
widthnumber-
heightnumber-
prioritybooleanfalse
sizesstring'100vw' in the dialog
widthsreadonly number[]-
transform(src, width) => stringIdentity
placeholderstring-
zoomLabelstringZoom image: <alt>
triggerClassNamestring-
classNamestring-