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
itemsis a list of{ src, alt, caption }. Give every imagealttext. Without it, the name is the caption, or "Image 2 of 8".v-modelis 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
labelsor a label pack:prev,next,zoomIn,zoomOut, andimage.
Usage
ts
import { BlessLightbox, type BlessLightboxItem } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
items* | BlessLightboxItem[] | — | |
loop | boolean | true | after the last image comes the first |
zoom | number | 2 | how much the zoom enlarges the image |
labels | Partial<{ prev: string; next: string; zoomIn: string; zoomOut: string; image: (n: number, of: number) => string; }> | — | |
modelValue | number | -1 | the index of the open image; -1 is closed |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: number] |