Skip to content
Calm motion: animations on this site only fade, with no movement

Lightbox ​

One image from a list, in full, with zoom and swipe

Shows one image of a list over the page, so a person can look at it closely and go through the list. Open it from any control. For a grid of thumbs that opens it, use the gallery, which uses this lightbox.

Basic
  • items is a list of { src, alt, caption }. Give every image alt text. Without it, the name is the caption, or "Image 2 of 8".
  • v-model is the index of the open image, and -1 is closed. Set it to open the lightbox, and it goes back to -1 when the lightbox closes.
  • The arrows, the ← and → keys, and a swipe to the side go to the previous and next image. In a right-to-left page, the keys and the swipe go the other way. loop (on by default) goes from the last image to the first.
  • The zoom button or a double click enlarges the image by zoom (default 2). Drag to move a large image. A new image starts with no zoom.
  • The lightbox is a modal: Escape closes it, and focus goes back to the control that opened it. The count is announced when the image changes.
  • Change the words with labels or a label pack: prev, next, zoomIn, zoomOut, and image.

Usage ​

ts
import { BlessLightbox, type BlessLightboxItem } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
items*BlessLightboxItem[]—
loopbooleantrueafter the last image comes the first
zoomnumber2how much the zoom enlarges the image
labelsPartial<{ prev: string; next: string; zoomIn: string; zoomOut: string; image: (n: number, of: number) => string; }>—
modelValuenumber-1the index of the open image; -1 is closed

Events

NamePayloadDescription
update:modelValue[value: number]

Released under the MIT License. Character names and artwork belong to their owners.