Skip to main content
VelinStyle v1.3.0
⌂ Home
  1. Docs
  2. Components
  3. Overlays
  4. Lightbox

Lightbox 1.2.2

<velin-lightbox> is a fullscreen media overlay for slotted images and videos. In 1.2.0, open/close uses focus-manager for background inert and scroll lock; close fires velin-close. Deutsch: Lightbox De

Maturity: Documented as stable in VelinStyle 1.2.0. Design Intelligence (plan / review / agent meta) is separate and beta / foundation where noted.

When to use

When not

Slot <img> (or <video>) children. Clicks call open(index). Optional data-velin-lightbox overrides the full-size URL (sanitized).

Mountain lake Dog portrait Misty forest
<velin-lightbox>
  <img src="photo-thumb-1.jpg"
       data-velin-lightbox="photo-full-1.jpg"
       alt="Mountain lake">
  <img src="photo-thumb-2.jpg"
       data-velin-lightbox="photo-full-2.jpg"
       alt="Dog portrait">
</velin-lightbox>

Keyboard navigation

While open, focus starts on the close button. / change slides, Escape closes, and Tab is trapped in the overlay. A polite live region and announce() report the slide counter.

<!-- Built-in keys: ArrowLeft / ArrowRight / Escape / Tab trap -->
<velin-lightbox>
  <img src="thumb1.jpg" alt="Slide 1">
  <img src="thumb2.jpg" alt="Slide 2">
</velin-lightbox>

Video support

Slot a <video> (or point data-velin-lightbox at a media URL). Video items render with controls and autoplay inside the overlay.

<velin-lightbox>
  <img src="photo-thumb.jpg" alt="Photo">
  <video src="clip.mp4" poster="video-poster.jpg"
         aria-label="Short clip"></video>
</velin-lightbox>

Accessibility

Dark, responsive, motion, RTL

API

Methods & events

APIDescription
open(index = 0)Opens at slide index; sets open; applies inert
close()Closes, clears inert, restores focus, fires velin-close
velin-closeBubbling close event

Slots & parts

NameDescription
Default slotIMG, VIDEO, or elements with data-velin-lightbox
Partsoverlay, content, counter

CSS variables

VariableDescription
--velin-z-modalOverlay z-index (default 500)
--velin-radius-mdMedia corner radius
--velin-color-focusFocus outline on controls

Best practices & pitfalls