All Challenges

Lightbox Image Gallery Modal with Caption & Nav

HTML/CSSEasyPinterestAirbnbAdobe
30:00

Problem Brief

Build a thumbnail gallery that opens a full-screen modal lightbox supporting Next/Prev item browsing and Escape close.

Requirements

  • Clicking `.thumb-btn` opens `[data-testid="lightbox"]` showing that item title.
  • Clicking `[data-testid="lb-next"]` / `[data-testid="lb-prev"]` cycles across gallery items.
  • Clicking `[data-testid="lb-close"]` or pressing `Escape` hides `[data-testid="lightbox"]`.
Progressive Hints (1)
  • Store `currentIndex` (`number | null`), toggle `.is-open` / `[hidden]` cleanly.
Reference Solution

Stuck? Load the verified reference code into your editor.

Automated Test Suite

2 Test Cases Ready
  • Opens selected thumbnail and cycles through captionsClick Ocean Reef, then Next -> Alpine Trail
  • Closes lightbox on Escape keyEscape key hides lightbox
solution.html
Live Sandboxed Previewiframe sandbox
Starter template loaded — add your <script> logic in the editor (or open Reference Solution) to make the widget interactive.