Skip to content
arturbienPublic

About

The lightbox for React. Unstyled, accessible primitives built on native scrolling and view transitions. Morph, swipe, zoom, and pull-to-dismiss, all out of the box.

Resources

Stars

183 stars

Watchers

1 watching

Forks

Repository files navigation

ramka

The lightbox for React. Unstyled, accessible gallery primitives in the style of Radix UI and Base UI, with shared-element View Transitions, native scroll swiping, pinch to zoom, and pull to dismiss.

ramka.dev · Documentation · Examples · License

A masonry photo grid where clicking a tile morphs it into a fullscreen lightbox and back

ramka — Polish for "frame".

Highlights

  • Morph view transitions. Shared-element View Transitions morph anything into the lightbox and back: images, video, plain HTML. Browsers without the API get a clean crossfade.
  • Native scrolling. Slides ride real CSS scroll snapping, not a transform-emulated carousel. Swiping feels native because it is.
  • Pinch to zoom. Pinch on touch or trackpad, double-tap to zoom, ctrl + scroll to zoom at the cursor. Pan with a finger, mouse, or arrow keys.
  • Pull to dismiss. Drag down on touch or wheel on a trackpad to close, like every photos app. Elastic, interruptible, and aware of zoom and in-flight swipes.
  • Headless and unstyled. Composable primitives with the API you know from Radix UI and Base UI: Trigger, Slides, Zoom, Captions, Thumbnails, Counter. You own every pixel.
  • Accessible by default. A focus-trapped dialog with full keyboard navigation, screen-reader naming hooks, and prefers-reduced-motion respected.
  • Typed and tiny. Fully typed, tree-shakeable, zero runtime dependencies. The zoom, morph, and pull engines lazy-load on demand, so a full gallery ships around 19 KB gzipped up front.
  • Images, video, anything. Photos, videos, 3D models, or any React content. Responsive srcset images, first-class next/image support, and RTL built in.

Quick start

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

<Lightbox.Root>
  {items.map((item) => (
    <Lightbox.Trigger key={item.id} itemId={item.id}>
      {({ imageRef }) => <img ref={imageRef} src={item.thumb} alt={item.alt} />}
    </Lightbox.Trigger>
  ))}

  <Lightbox.Portal>
    <Lightbox.Backdrop />
    <Lightbox.Content aria-label="Photo viewer">
      <Lightbox.Slides aria-label="Photos">
        {items.map((item, i) => (
          <Lightbox.Slide key={item.id}>
            <Lightbox.Item index={i} itemId={item.id} caption={item.caption}>
              <Lightbox.Zoom>
                <Lightbox.Media>
                  <img src={item.src} alt={item.alt} />
                </Lightbox.Media>
              </Lightbox.Zoom>
            </Lightbox.Item>
          </Lightbox.Slide>
        ))}
      </Lightbox.Slides>
      <Lightbox.Close aria-label="Close" />
    </Lightbox.Content>
  </Lightbox.Portal>
</Lightbox.Root>;

Every part is unstyled: bring your own CSS, or start from a copy-paste preset. The full walkthrough is at ramka.dev/docs.

Documentation

Package-level details (tree-shaking, CSP, supply chain, localization) live in the @ramka/react README.

Development

This repository is a pnpm + Turborepo monorepo containing:

  • packages/ramka — the publishable component library (@ramka/react).
  • apps/docs — the Next.js documentation site, styled with Tailwind CSS.

Prerequisites: Node.js >= 18 (developed against Node 22 — see .nvmrc) and pnpm 9.

pnpm install
pnpm dev

pnpm dev runs the library in watch mode and the docs site (http://localhost:3000) in parallel via Turborepo.

Command Description
pnpm dev Run the library watcher and the docs site in parallel.
pnpm build Build the library, then the docs site.
pnpm lint Lint every workspace.
pnpm typecheck Type-check every workspace.
pnpm format Format the repo with Prettier.
pnpm clean Remove build artifacts and node_modules.

License

MIT. Free for open-source and proprietary software.

About

The lightbox for React. Unstyled, accessible primitives built on native scrolling and view transitions. Morph, swipe, zoom, and pull-to-dismiss, all out of the box.

Resources

Stars

183 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages