Image Viewer

A composable React image viewer for galleries and attachment previews, with animated lightbox variants, custom thumbnails and controls, swipe and keyboard navigation, zoom and pan, accessible focus management, and controlled or uncontrolled selection.

Morphing

morphing-lightbox.tsx

A thumbnail-connected image viewer with composable gallery, thumbnail, content, caption and navigation parts, plus a shared state hook. Expand into the full-size image and return to the thumbnail on close, with swipe navigation, zoom and pan.

Collected moments

Look a little closer.

3 photographs

Open a photograph. Swipe or use the arrows to explore.

Install

$ bunx --bun shadcn add @beui/morphing-lightbox

API Reference

ImageViewer

images
LightboxImage[]
—
value?
string | null
—
defaultValue?
string | null
null
onValueChange?
((id: string | null) => void)
—
label?
string
Image gallery
className?
string
—
thumbnailClassName?
string
—
renderCaption?
((image: LightboxImage) => ReactNode)
—
children?
ReactNode

Compose gallery and viewer parts instead of the default layout.

—

ImageViewerGallery

className?
string
—

ImageViewerThumbnail

imageId
string
—
imageClassName?
string
—
className?
string
—

ImageViewerCounter

className?
string
—

ImageViewerCaption

className?
string
—

ImageViewerClose

className?
string
—

ImageViewerPrevious

className?
string
—

ImageViewerNext

className?
string
—

ImageViewerContent

className?
string
—
header?
ReactNode

Custom header; defaults to the counter and close control.

—
children?
ReactNode

Custom footer; defaults to navigation and the image caption.

—

Updated