Gallery✨ Premium

Fullscreen Lightbox

The clicked photo goes into the browser's real fullscreen over an almost black background; on iPhone, where that mode does not exist, it covers the whole window.

JSFullscreenImmersive

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →

3 usage examples

House plans projected in a meeting from an architect's client area — Fullscreen Lightbox example 1

① House plans projected in a meeting from an architect's client area

WhenAt Ferandole Architects, the meeting-room computer is connected to the projector: the architect clicks the ground-floor plan and it fills the projected screen, with no bar or tab.
WhyProjected, a plan must use the whole surface so dimensions can be read from the back of the room; real fullscreen removes everything distracting.
SettingsFour 4:3 thumbnails in one row, plan name and revision below. For a detailed plan, supply a wide image (at least 2000 px) or data-full: the image is never enlarged beyond its size.
Diagram of one step in assembling flat-pack furniture — Fullscreen Lightbox example 2

② Diagram of one step in assembling flat-pack furniture

WhenOn the online instructions for a Tiravelle bookcase, step 3 shows a small diagram; with the tablet on the floor next to the parts, one tap shows it fullscreen.
WhyDuring assembly you look at the diagram from a distance with your hands busy: fullscreen makes it readable from a metre away, and ✕ brings back the list of steps.
SettingsA single thumbnail in a white card, with “Full screen ⤢” written below; orange --fslb-accent.
QR code of an e-ticket shown at the gate — Fullscreen Lightbox example 3

③ QR code of an e-ticket shown at the gate

WhenAt the Vendemiel festival entrance, the visitor taps the QR code on their ticket: it shows large on a dark background, ready to scan.
WhyA small QR code surrounded by text scans badly; large and isolated, it works first time. On iPhone fullscreen does not exist, but the viewer still covers the window: the result stays usable.
Settings84 px square thumbnail (aspect-ratio: 1 / 1 added by the scene) inside the ticket. The capture shows the viewer covering the window: a capture browser does not display real fullscreen.

How it works

On a click on a .fslb-thumb thumbnail, the script opens the modal <dialog>, then requests fullscreen for .fslb-stage, the stage inside it (a <dialog> itself cannot go fullscreen: all three engines refuse). The request is made during the click, as browsers require.

In fullscreen, bars and tabs disappear: the photo is shown as large as possible, up to 90 % of the screen width and 85 % of its height, on rgba(0, 0, 0, 0.98), with ✕ fixed at the top right. If you leave fullscreen with the browser's Escape key, the fullscreenchange event closes the viewer too; ✕ or a click on the black does both at once.

When fullscreen is refused (iPhone, a page inside an <iframe> without allow="fullscreen", an older browser), the request fails silently and nothing else changes: the dialog already fills the whole window, only the browser bars stay visible. Measured by forcing that refusal: a 1280 × 800 stage in a 1280 × 800 window.

Accessibility

  • Buttons and name: thumbnails are <button> elements, ✕ is named “Close”, the viewer is named “Image viewer”.
  • Focus: placed on ✕ on opening, kept inside the viewer (page behind inert), returned to the thumbnail on closing, including when leaving through the fullscreen Escape key.
  • Escape: in fullscreen the browser uses it to leave that mode and the viewer closes along with it; without fullscreen, the script closes.
  • Reduced motion: no fade and no growth; fullscreen is requested in the same way.
  • Caveat: fullscreen removes the browser's landmarks; keep ✕ visible (it is by default) and never open it without a user click.

Browser compatibility

Unprefixed Fullscreen API: Chrome 71, Firefox 64, Safari 16.4; on iOS, iPad only (@mdn/browser-compat-data: “Only available on iPad, not on iPhone”). The rest follows the viewers' base (modal <dialog>: Firefox 98, Safari 15.4). Fullscreen obtained in Chromium 151, Firefox 153 and WebKit 26.5; leaving fullscreen closes the viewer in all three.

Chrome 88+✓ Full (measured)
Firefox 98+✓ Full (measured)
Safari 15.4+✓ Full from 16.4 (measured on WebKit); 15.4 to 16.3: the viewer covers the window without fullscreen
Edge 88+✓ Full (Chromium engine)
Mobile iOS 15.4+✓ Partial: no fullscreen on iPhone, the viewer covers the window; iPad 16.4+ gets real fullscreen
Android Chrome 88+✓ Full (touch measured)

iPhone, Safari 15.4 to 16.3 and iframes without permission: the viewer covers the window (fixed position, 100 % × 100 %) and the image keeps the same maximum size. Without showModal(), nothing opens.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0176-root">
  <div class="fslb-grid">
    <button type="button" class="fslb-thumb" aria-haspopup="dialog"><img src="photo.jpg" alt="Amber to red gradient" width="1920" height="1280"></button>
    <button type="button" class="fslb-thumb" aria-haspopup="dialog"><img src="photo.jpg" alt="Pink to violet gradient" width="1920" height="1280"></button>
    <button type="button" class="fslb-thumb" aria-haspopup="dialog"><img src="photo.jpg" alt="Indigo to violet gradient" width="1920" height="1280"></button>
    <button type="button" class="fslb-thumb" aria-haspopup="dialog"><img src="photo.jpg" alt="Cyan to emerald gradient" width="1920" height="1280"></button>
  </div>
  <dialog class="fslb-viewer" aria-label="Image viewer">
    <div class="fslb-stage">
      <button type="button" class="fslb-close" aria-label="Close"><svg>…</svg></button>
      <img class="fslb-image" alt="">
    </div>
  </dialog>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Maximum image size (CSS — .fslb-image) max-width: 90vw; max-height: 85vh The image is never enlarged beyond its real size: use wide photos or data-full.
Stage background (CSS — .fslb-stage) rgba(0, 0, 0, 0.98) The stage, not the dialog, goes fullscreen: its colour is the one you see.
✕ position (CSS — .fslb-close) fixed, 20 px from top and right Stays visible in fullscreen and in window mode alike.
Thumbnails (CSS — --fslb-thumb, --fslb-gap) 120px, 10px Width (3:2 format) and spacing of the buttons on the page.
Large image (HTML — data-full) absent URL loaded on opening instead of the thumbnail.
Fullscreen inside an iframe (HTML — allow="fullscreen") not allowed by default Without this attribute on the <iframe> holding the gallery, the browser refuses and the viewer stays in window mode.

FAQ

Safari on iPhone does not offer the Fullscreen API for page elements (only for videos), whereas iPad has had it since Safari 16.4. The script copes: the viewer covers the whole window and Safari's bars stay visible.
Yes. In fullscreen the browser keeps Escape for itself and leaves that mode; the script listens to fullscreenchange on the stage and closes the viewer right away. Outside fullscreen, Escape is handled directly.
Not in this version, which shows one photo per opening. Arrows and swiping are in the lightbox with navigation from the same category.