---
title: "ZoomImage"
description: "The component for images that open full screen."
canonical_url: "https://kukson777.github.io/nuxt-image-viewer/docs/guide/zoom-image"
---
# ZoomImage

> The component for images that open full screen.

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

```vue
<template>
  <ZoomImage
    src="/photos/dawn.jpg"
    :width="2400"
    :height="1600"
    caption="Alpine dawn"
    class="rounded-xl object-cover"
    loading="lazy"
  />
</template>
```

<demo-gallery>



</demo-gallery>

## Props

<field-group>
<field name="src" type="string" :required="true">

The full-size image. The viewer opens it; with Nuxt Image the page shows an optimized copy.

</field>

<field name="width" type="number" :required="true">

Natural width of `src`.

</field>

<field name="height" type="number" :required="true">

Natural height of `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×.

</field>

<field name="caption" type="string">

Text under the image in the viewer. Also the default `alt`.

</field>

<field name="alt" type="string">

Alternative text. Falls back to `caption`, then to an empty string.

</field>
</field-group>

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.

```vue
<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()`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/options) takes, on top of the global ones:

```vue
<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](https://kukson777.github.io/nuxt-image-viewer/docs/customization/custom-buttons) — and its own arrows, as `#prev` / `#next` slots.

## With Nuxt Image

When [`@nuxt/image`](https://image.nuxt.com) 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.

```vue
<template>
  <ZoomImage
    src="/photos/dawn.jpg"
    :width="2400"
    :height="1600"
    sizes="320px md:400px"
    format="webp"
  />
</template>
```

<tip>

That's what this site does: the thumbnails above are 320 px WebP copies from `/_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.

</tip>

Detection is automatic. Force it either way with the [`nuxtImage`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/options#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.

```vue
<template>
  <ZoomImage
    v-bind="photo"
    class="aspect-square rounded-2xl object-cover"
  />
</template>
```

## Renaming the component

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  imageViewer: {
    componentName: 'LightboxImage', // or false to not register it at all
  },
})
```


## Sitemap

See the full [sitemap](https://kukson777.github.io/nuxt-image-viewer/sitemap.md) for all pages.
