Lightbox

Accessible primitives for fullscreen media lightboxes — compound parts in the style of Base UI and Radix. Cosmetically unstyled: you own colors, chrome, and radius values. Ramka owns state, focus, gestures, morphs, and structural styles required for those mechanics.

Usage guidelines

Work through these decisions in order:

  1. State — controlled props, createHandle, or both? See State & lifecycle.
  2. Layout — default to the swipe carousel (Slides + Zoom). See Composition.
  3. Morph — on by default; wrap destination media in Lightbox.Media (and imageRef on Trigger thumbs), choose crossfade / morphTo, or pass viewTransition={false} to opt out. See View transitions.
  4. Gestures — pull-to-dismiss on Content, Zoom on media, keyboard on Content. See Gestures.
  5. Cosmetics vs mechanics — colors, chrome, and radius values are yours. Structural styles (view-transition morph CSS, morph host box, zoom overflow, slide snap alignment, placeholders) are applied by the library or via Media width/height; slide track width (full-bleed vs snug cards) is consumer CSS — see Composition → Slides + Zoom. Style with documented data-* attributes and CSS variables from the API reference.

Anatomy

Import the namespace and compose parts. The sketch below is the default gallery shape (Slides + Zoom + chrome). Every part is optional except Root for state.

Anatomy
import * as Lightbox from '@ramka/react/lightbox';

<Lightbox.Root>
  <Lightbox.Trigger index={0}>{/* thumb */}</Lightbox.Trigger>
  <Lightbox.Portal>
    <Lightbox.Backdrop />
    <Lightbox.Content>
      <Lightbox.Slides>
        <Lightbox.Slide>
          <Lightbox.Item index={0}>
            <Lightbox.Zoom>
              <Lightbox.Media>
                <img alt="" />
              </Lightbox.Media>
            </Lightbox.Zoom>
          </Lightbox.Item>
        </Lightbox.Slide>
      </Lightbox.Slides>
      <Lightbox.Counter />
      <Lightbox.ZoomOut aria-label="Zoom out" />
      <Lightbox.ZoomIn aria-label="Zoom in" />
      <Lightbox.Close aria-label="Close" />
      <Lightbox.Caption />
    </Lightbox.Content>
  </Lightbox.Portal>
</Lightbox.Root>

Next steps