Image Gallery
A responsive grid of images with an interactive lightbox viewer featuring zoom, keyboard navigation, and thumbnail strip.
Basic
A responsive grid of images with an interactive lightbox viewer featuring zoom, keyboard navigation, and thumbnail strip. Click any image to open the lightbox.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add image-gallerypnpm dlx @work-rjkashyap/unified-ui add image-gallerynpx @work-rjkashyap/unified-ui add image-gallerybunx @work-rjkashyap/unified-ui add image-galleryIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import { ImageGallery } from "@work-rjkashyap/unified-ui";Examples
Columns
2 columns
4 columns
Aspect Ratios
square
video (16:9)
Custom Gap
gap=2
gap=16
Without Lightbox
With Captions
Single Image
Props
| Prop | Type | Default | Description |
|---|---|---|---|
images | GalleryImage[] | — | Array of images to display. |
columns | 1 | 2 | 3 | 4 | 3 | Number of grid columns. |
gap | number | 8 | Gap between grid items in pixels. |
aspectRatio | "square" | "video" | "auto" | "square" | Aspect ratio for thumbnails. |
lightbox | boolean | true | Whether to enable the lightbox on click. |
className | string | — | Additional CSS classes on the grid. |
renderThumbnail | (image, index) => ReactNode | — | Custom thumbnail renderer. |
GalleryImage
| Property | Type | Description |
|---|---|---|
src | string | Image source URL. |
alt | string | Alt text for accessibility. |
thumbnail | string | Optional thumbnail URL (falls back to src). |
caption | string | Optional caption shown in lightbox. |
Keyboard Navigation
| Key | Action |
|---|---|
← / → | Previous / Next image |
Escape | Close lightbox |
| Click image | Toggle zoom |
Accessibility
- Grid uses
role="group"witharia-label. - Lightbox uses
role="dialog"witharia-modal. - All images require
alttext for screen readers. - Full keyboard navigation support in lightbox.
- Thumbnail strip buttons use
aria-currentfor the active image. - Respects
prefers-reduced-motion— animations are disabled when the user prefers reduced motion.
Always provide descriptive alt text for each image. Captions are optional
but recommended for galleries with meaningful content.
Design Tokens
| Token | Usage |
|---|---|
--border | Thumbnail border |
--muted | Thumbnail background |
--radius-lg | Thumbnail border radius |
--shadow-md | Hover shadow on thumbnails |
--duration-fast | Transition speed |