Back to components
ElementOverlayFree

Lightbox React component

An image lightbox for any grid of photos: the thumbnail morphs into the full view, then arrows, keys and swipes step through, double-click zooms and pans, a swipe down closes, and a thumbnail strip tracks where you are.

About the Lightbox component

Lightbox shows a grid of image thumbnails that open into a full-screen viewer, with the clicked thumbnail growing smoothly into the large image. The viewer has a caption, a counter, previous and next buttons, a strip of thumbnails along the bottom and a 2x zoom, and it closes with a swipe down, Escape or the close button.

images takes objects with src, alt, an optional caption and an optional smaller thumb for the grid and the strip. columns sets the grid columns. showGrid={false} hides the grid so you can open the viewer from your own layout with index and onIndexChange (null means closed). showThumbnails toggles the strip, loop wraps from the last image to the first, and contained keeps the viewer inside a positioned parent instead of covering the page. It is a modal dialog that takes focus and gives it back when closed.

When to use it

Use Lightbox wherever people should look at photos properly without leaving the page: product images, portfolios, event albums, user uploads. The thumbnail grows into the full view, so it's always clear which picture opened.

Use showGrid={false} with index when the thumbnails are part of your own layout (a product gallery, a feed) and you only need the viewer.

Installation

Add the Lightbox component to your project with the shadcn CLI. It lands in components/lightbox.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/lightbox

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

Related components

Cookie Consent Banner
Free
Bottom Sheet
Free
Product Tour
Free
Command Palette
Free
Drawer
Free
Popover
Free