EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Lightbox·component·@astryxdesign/core

Lightbox

A fullscreen overlay for viewing images and videos at full resolution. Supports single-item and gallery modes with prev/next navigation, optional zoom and pan for images, and native video controls.

Open in Playground @astryxdesign/core/Lightbox

Showcases and examples

4 documented examples

Lightbox

A fullscreen image viewer with caption.

Preview loads on approachPreview loads on approach
Exact source · lightbox-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

import {useState} from 'react';
import {Lightbox} from '@astryxdesign/core/Lightbox';

export default function LightboxShowcase() {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <>
      <button onClick={() => setIsOpen(true)}>View image</button>
      <Lightbox
        isOpen={isOpen}
        onOpenChange={setIsOpen}
        media={{
          src: '/template-assets/light-scene-horizontal-1.png',
          alt: 'Coastal shoreline with ocean waves',
          caption:
            'A scenic coastline with waves rolling onto a sandy beach beneath a clear sky.',
        }}
      />
    </>
  );
}

Usage

A fullscreen overlay for viewing images and videos at full resolution. Supports single-item and gallery modes with prev/next navigation, optional zoom and pan for images, and native video controls.

  • Always provide alt text for every image for screen reader accessibility.
  • Use gallery mode with onIndexChange for multi-image sets.
  • Enable hasZoom only when viewing high-resolution images that benefit from close inspection.
  • Use the lightbox for non-image content; it is specialized for images.
  • Nest interactive content inside captions; keep them plain text.

Typed props

PropType and behavior
isOpenboolean · required
Whether the lightbox is open.
onOpenChange(isOpen: boolean) => void · required
Callback when the lightbox open state changes.
mediaLightboxMedia | LightboxMedia[] · required
Media to display. Pass a single object for one item, or an array for gallery mode with prev/next navigation. Each item is {src: string, alt: string, caption?: ReactNode, type?: 'image' | 'video'}; type defaults to 'image', and zoom/pan is disabled for 'video'.
indexnumber
Current index in gallery mode (when media is an array).
onIndexChange(index: number) => void
Callback when the gallery index changes via prev/next navigation.
hasZoomboolean · default false
Enable zoom on double-click, or Enter/Space/+/- via keyboard (images only). When zoomed, drag or use arrow keys to pan.
defaultIndexnumber · default 0
Initial image index in gallery mode for uncontrolled usage.
hasAutoPlayboolean · default false
Automatically start video playback when a video media item is shown.
xstyleStyleXStyles
StyleX styles for layout customization. Must be stylex.create() value.

Anatomy

Viewer overlay · required

Full-viewport dialog overlay that contains the active media and controls.

Media · required

Active image or video presented inside the viewer.

Close button · required

Button that closes the viewer.

Previous button · optional

Gallery button that moves to the previous media item.

Next button · optional

Gallery button that moves to the next media item.

Caption · optional

Caller-provided caption displayed below the active media.

Counter · optional

Current position and total shown in gallery mode.

Theming

Targets

astryx-lightbox