ZoomImage
<ZoomImage> renders an image that opens the viewer on click, Enter and Space. It only sets attributes — the global plugin does the rest, so there are no handlers per image.
<template>
<ZoomImage
src="/photos/dawn.jpg"
:width="2400"
:height="1600"
caption="Alpine dawn"
class="rounded-xl object-cover"
loading="lazy"
/>
</template>






Props
src.src. Together with width it tells the viewer how to fit the image and how far it can zoom: up to the natural size, but at least 2×.alt.caption, then to an empty string.Every other attribute — class, style, loading, sizes, decoding, Nuxt Image props — passes through to the rendered image.
Groups
The viewer scrolls through the images of the closest [data-image-viewer-group]. Without one, it scrolls through every marked image of the page.
<template>
<article data-image-viewer-group>
<ZoomImage v-bind="first" />
<p>Text in between doesn't matter.</p>
<ZoomImage v-bind="second" />
</article>
<aside data-image-viewer-group>
<!-- a separate gallery -->
</aside>
</template>
A group with its own options
<ImageViewerGroup> is such a group with options for its images only — anything open() takes, on top of the global ones:
<template>
<ImageViewerGroup :options="{ loop: false, ui: { counter: false } }">
<ZoomImage v-for="photo in photos" :key="photo.src" v-bind="photo" />
</ImageViewerGroup>
</template>
It renders a <div>; as="section" makes it another tag. That's also the way to give one gallery its own buttons — and its own arrows, as #prev / #next slots.
With Nuxt Image
When @nuxt/image is installed, the component renders <NuxtImg> instead of <img>. The page shows an optimized copy — use sizes to keep it small — and the viewer loads the original src on top of it.
<template>
<ZoomImage
src="/photos/dawn.jpg"
:width="2400"
:height="1600"
sizes="320px md:400px"
format="webp"
/>
</template>
/_ipx (640 px on high-density screens), and the viewer opens the 2400 px originals. Until the original arrives, the viewer shows the copy already on the page — so there is never an empty frame.Detection is automatic. Force it either way with the nuxtImage option.
Thumbnails that crop
Cropped thumbnails are fine: with object-fit: cover or contain (and any object-position) the image flies out of the visible crop and back into it, and rounded corners are animated too.
<template>
<ZoomImage
v-bind="photo"
class="aspect-square rounded-2xl object-cover"
/>
</template>
Renaming the component
export default defineNuxtConfig({
imageViewer: {
componentName: 'LightboxImage', // or false to not register it at all
},
})