Skip to content
LoidoltTheme 0.11.1
Svelte 5

Component

Lightbox

A full-screen viewer for a list of media, with zoom, swipe and thumbnails.

import { Lightbox } from '@loidolt/theme-svelte';

Example

Notes

  • Arrow keys, Home and End move between items; + and − zoom an image, 0 resets it. Pinch, Ctrl + wheel and double-click zoom too, and dragging pans a zoomed image.
  • Swipe to move on when the image is not zoomed. The next and previous images are loaded ahead of time.
  • Each move is announced once ("Canyon relief, cork, 2 of 6") through a live region; the visible counter is hidden from assistive tech so it is not read twice.
  • Videos, audio and embeds play in place with their own controls.

Props

Generated from the component source, so it cannot drift from the implementation.

Lightbox props
PropTypeDefaultNotes
items required MediaItem[]—
class string—Lands on the dialog content.
closeLabel string'Close viewer'
counterText (position: number, count: number) => string(position, count) => `${position} of ${count}`
downloadable booleanfalseOffer a download link for images that set download.
downloadLabel string'Download'
index bindablenumber0The item showing, 0-based.
loop booleantrueWrap from the last item to the first.
nextLabel string'Next'
onIndexChange (index: number) => void—
onOpenChange (open: boolean) => void—
open bindablebooleanfalse
previousLabel string'Previous'
ref bindableHTMLElement | nullnull
showCaption booleantrue
showCounter booleantrue
showThumbnails booleanfalse
thumbnailsLabel string'All items'
title string'Media viewer'Accessible name of the dialog.
trigger Snippet—Opens the lightbox. Leave it out to drive open yourself, as MediaGrid does.
triggerChild Snippet<[TriggerChildProps]>—
triggerClass string'ldt-button'
zoomable booleantrueLet images be zoomed and panned: pinch, Ctrl + wheel, double-click, or + and −.
zoomInLabel string'Zoom in'
zoomOutLabel string'Zoom out'