Skip to content

Configuration

Nuxt Easy Lightbox configures behaviour through props on the <VueEasyLightbox /> component, not through nuxt.config.ts. The module’s only job is to register the component and inject its CSS — everything below is set per usage.

visible and imgs are the only required props; everything else is optional.

PropTypeDefaultDescription
visiblebooleanRequired. Controls whether the lightbox is shown.
imgsstring | string[] | ImgObject | ImgObject[]Required. Image(s) to display. A string URL, an { src, title?, alt? } object, or an array mixing both.
indexnumber0Index of the image to open first when imgs is an array.
loopbooleanfalseEnable continuous looping when paging past the first/last image.
scrollDisabledbooleantrueDisable page scrolling while the lightbox is open.
escDisabledbooleanfalseDisable closing the lightbox with the Esc key.
moveDisabledbooleanfalseDisable drag-to-pan (enables swipe instead).
rotateDisabledbooleanfalseDisable image rotation.
zoomDisabledbooleanfalseDisable zooming.
pinchDisabledbooleanfalseDisable pinch-to-zoom on touch devices.
maskClosablebooleantrueAllow clicking the backdrop mask to close the lightbox.
dblclickDisabledbooleanfalseDisable double-click (double-tap) to zoom in/out.
teleportstring | ElementTarget node to teleport the lightbox into (CSS selector or element).
swipeTolerancenumber50Pixels the user must swipe before paging to the next/previous image.
zoomScalenumber0.12Step size between zoom levels.
maxZoomnumber3Maximum zoom level.
minZoomnumber0.1Minimum zoom level.
rtlbooleanfalseEnable right-to-left layout for RTL languages.

The ImgObject shape:

interface ImgObject {
src: string
title?: string
alt?: string
}
EventPayloadDescription
hideEmitted when the user closes the lightbox (mask click, close button, or Esc). Set visible to false here.
on-errorEventEmitted when an image fails to load.
on-prev / on-prev-click(oldIndex, newIndex)Emitted when the previous control is used or the user swipes to the previous image.
on-next / on-next-click(oldIndex, newIndex)Emitted when the next control is used or the user swipes to the next image.
on-index-change(oldIndex, newIndex)Emitted whenever the displayed image index changes.
on-rotate(deg: number)Emitted when the image is rotated, with the new clockwise angle.

Every visual control can be replaced with a scoped slot.

SlotSlot propsDescription
prev-btn{ prev }Custom “previous image” button. Call prev() to go back.
next-btn{ next }Custom “next image” button. Call next() to advance.
close-btn{ close }Custom close button. Call close() to dismiss.
toolbar{ toolbarMethods }Custom toolbar. toolbarMethods exposes zoomIn, zoomOut, rotate, rotateLeft, rotateRight.
loadingCustom loading indicator shown while an image loads.
onerrorCustom placeholder shown when an image fails to load.
<template>
<VueEasyLightbox
:visible="visible"
:imgs="imgs"
@hide="visible = false"
>
<template #toolbar="{ toolbarMethods }">
<div class="my-toolbar">
<button @click="toolbarMethods.zoomIn">Zoom in</button>
<button @click="toolbarMethods.zoomOut">Zoom out</button>
<button @click="toolbarMethods.rotateLeft">Rotate left</button>
<button @click="toolbarMethods.rotateRight">Rotate right</button>
</div>
</template>
</VueEasyLightbox>
</template>