Skip to content

Lightbox

@astryxdesign/core v0.7.1 · Lightbox

Props ​

NameTypeDefaultDescription
isOpenboolean—Whether the dialog is open. Bind with v-model:is-open.
mediaLightboxMedia | readonly LightboxMedia[]—One item, or a gallery. An array shows previous, next, and a counter.
indexnumber—Controlled gallery index. Bind with v-model:index.
defaultIndexnumber0Initial index when index is omitted.
hasZoombooleanfalseDouble-click, Enter, Space, +, and - zoom images. Arrow keys pan while zoomed.
hasAutoPlaybooleanfalseStart video playback when a video item is shown.

LightboxMedia is { src, alt, caption?, type? }. type is image or video, and defaults to image.

Events ​

NamePayloadDescription
update:isOpenbooleanClose, Escape, or a backdrop click asks to change the open state.
update:indexnumberPrevious, next, or an arrow key while zoomed out asks for a new gallery index.

useLightbox ​

ts
const { bindings, open, close, isOpen, index, getTriggerProps } = useLightbox({
  media,
  hasZoom: false,
  hasAutoPlay: false,
})

bindings is the set of props and update listeners for v-bind. open(index) sets the index and opens the dialog. getTriggerProps(index) returns role="button", tabindex="0", aria-haspopup="dialog", and keyboard activation for a custom trigger.

Theme ​

The dialog class is astryx-lightbox. Caption text uses the large type, on-dark, a max width of 600px, and padding of spacing 2 on the block start and spacing 3 on the inline sides. Close and navigation sit at spacing 3 from the frame.