Getting Started
Quick start
The three ways to open the viewer, in five minutes.
A gallery
Put images in a container with data-image-viewer-group: the viewer scrolls through the images of that group only. Without a group it scrolls through every marked image of the page.
<template>
<div class="gallery" data-image-viewer-group>
<ZoomImage
v-for="photo in photos"
:key="photo.src"
v-bind="photo"
/>
</div>
</template>
<script setup lang="ts">
const photos = [
{ src: '/photos/dawn.jpg', width: 2400, height: 1600, caption: 'Alpine dawn' },
{ src: '/photos/dusk.jpg', width: 1600, height: 2400, caption: 'Dusk' },
]
</script>






width and height are the natural size of the full image, not the size on the page. The viewer fits and zooms the image by them — up to its natural size, but at least 2×.Images you already have
HTML from a CMS or Markdown doesn't need the component — tag the <img>:
<img
src="/photos/dawn-small.jpg"
alt="Dawn"
tabindex="0"
data-image-viewer
data-image-viewer-src="/photos/dawn.jpg"
data-image-viewer-width="2400"
data-image-viewer-height="1600"
>
From code
const viewer = useImageViewer()
viewer.open([
{ src: '/photos/dawn.jpg', width: 2400, height: 1600 },
{ src: '/photos/dusk.jpg' }, // no size: measured before opening
])
isOpen: false index: 0