Skip to main content

Lightbox, gestures, and accessibility

Understand modal ownership, opening animation, input, focus, and reduced motion.

The included lightbox is a modal viewer. While open, it owns keyboard input, moves focus into the viewer, and makes the page behind it inert.

Use touch and pointer gestures

The preview records pointer input. Open the lightbox for real pan, pinch, and swipe behavior.

Desert landscape at golden hour
Ocean waves reflecting light
Canyon at dusk
Misty forest
<PhotoAlbum :photos="photos" transition="auto" />

Follow keyboard and focus behavior

Open with Enter, navigate with arrow keys, and close with Escape.

Desert landscape at golden hour
Ocean waves reflecting light
Canyon at dusk
Misty forest
Mountain peak framed by trees
<PhotoAlbum :photos="photos" layout="rows" />

Opening animation

A FLIP transition measures the thumbnail's first position and the slide's final position, then animates between them. FLIP means First, Last, Invert, Play.

ModeBehavior
autoUses FLIP when enough of the thumbnail is visible; otherwise fades.
flipAlways tries to animate from the thumbnail.
fadeCross-fades without moving from the thumbnail.
noneOpens without a transition.

auto is the default. autoThreshold defaults to 0.55, which means at least 55 percent of the thumbnail must be visible. Raise the threshold when movement from partly hidden thumbnails is distracting.

Closing returns to the original visible thumbnail when possible. It fades when that thumbnail is gone or outside the viewport.

Keyboard controls

KeyAction
EscapeClose and restore focus to the opening control.
ArrowRightShow the next photo, or pan when the current image is zoomed.
ArrowLeftShow the previous photo, or pan when zoomed.
HomeShow the first photo.
EndShow the last photo.
zToggle the secondary zoom level.
TabMove through the lightbox controls.

Right-to-left direction reverses directional navigation. Text fields, text areas, selects, and editable content keep their keyboard input. Other controls receive the event before the lightbox. Call event.preventDefault() from a custom control when it must suppress a built-in shortcut such as Escape, an arrow key, Home, End, or z.

Pointer gestures

Dragging moves a zoomed image. A horizontal drag at the fitted scale can settle on the previous or next photo. Pinch and wheel input change zoom where the device supports them.

Reduced motion

Nuxt Photo observes prefers-reduced-motion. It replaces movement-heavy transitions with a short fade and reacts when the preference changes. Custom lightbox content must provide its own reduced-motion treatment.

Use native buttons for custom controls and retain visible focus styles. The primitives guide shows the lower-level structure.