Black Friday is here 🔥 Get Wensity Pro for 20% less with

Image Lightbox

Pro

A React image lightbox: photos grow from their grid tile, then zoom, swipe and step through with the arrow keys.

lightboxgalleryimageszoomswipemodal
Image Lightbox component preview

Overview

Image Lightbox is a React and Tailwind CSS lightbox gallery that opens photos from a grid into a full-screen viewer, in Next.js or any React app. The clicked tile grows into the full photo and shrinks back on close, on Framer Motion values with no re-renders. Double tap, pinch or scroll the wheel to zoom, swipe or press the arrow keys to change photo, and pull down or press Escape to close. Focus stays inside the dialog. Reduced motion swaps movement for a short fade. Pass each image's width and height so its shape is known before it loads.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add image-lightbox

Usage

Import ImageLightbox from @/components/wensity/image-lightbox and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { ImageLightbox } from "@/components/wensity/image-lightbox";
const images = [
{ src: "/photos/stair.jpg", alt: "Spiral staircase", caption: "Spiral stair" },
{ src: "/photos/house.jpg", alt: "Concrete house", caption: "Desert house" },
{ src: "/photos/pool.jpg", alt: "Pool villa", caption: "Pool villa" },
];
export default function Example() {
return <ImageLightbox images={images} columns={3} />;
}

Props

PropTypeDefaultDescription
imagesLightboxImage[]-Photos to show. Each has src and alt, plus optional thumbSrc, caption, width, height and featured (a double-size grid tile).
columns2 | 3 | 43Grid columns on tablets and up. Phones always get two.
thumbnailAspectnumber4 / 3Width divided by height of each grid tile.
indexnumber | null-Controlled open photo. Pass null to close.
defaultIndexnumber | nullnullPhoto that starts open when uncontrolled.
onIndexChange(index: number | null) => void-Called when the open photo changes or the lightbox closes.
loopbooleantrueWrap from the last photo back to the first.
maxZoomnumber3Largest zoom, as a multiple of the fitted size.
showThumbnailsbooleantrueShow the thumbnail filmstrip along the bottom.
showCaptionbooleantrueShow each photo's caption under it.
closeOnBackdropbooleantrueClose on a click or tap outside the photo.
labelstring"Image gallery"Accessible name of the dialog.
children({ open }) => ReactNode-Replace the built-in grid with your own triggers and call open(index).
  • macOS Floating Dock component preview

    macOS Floating Dock

    A magnetic dock where icons inflate near the cursor and push their siblings aside.

  • Multi-Select Tag Input component preview

    Multi-Select Tag Input

    A tag input where pills pop in as you add them and slide out on remove, closing the gap without snapping the layout.

  • Shimmering Skeleton Wrapper component preview

    Shimmering Skeleton Wrapper

    One angled GPU sweep that travels across any placeholder geometry you wrap, never a separate shimmer stuttering per row.

  • Cool Button component preview

    Cool Button

    A dual-layer orbit glow that soft-spins around the edge of any button or link you wrap it around, at zero layout cost.