StealThis .dev

Image Lightbox

Click-to-open image lightbox with overlay, zoom, keyboard navigation (←→ Escape), and swipe support on mobile.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Image Lightbox

A zero-dependency image lightbox with smooth open/close transitions, keyboard navigation, and mobile swipe support. Click any image in the gallery to open it full-screen.

Features

  • Grid gallery with hover overlay
  • Smooth fade+scale open/close transition
  • Keyboard navigation: / to navigate, Escape to close
  • Touch swipe support (left/right) on mobile
  • Counter indicator (e.g., “3 / 6”)
  • Traps focus inside the lightbox when open
  • aria-modal dialog pattern with backdrop click-to-close
  • Body scroll locked while lightbox is open

Keyboard shortcuts

KeyAction
Previous image
Next image
EscapeClose lightbox

Swipe

Swipe left to go to the next image, swipe right to go to the previous image. Minimum swipe distance: 50px.