Unified UI

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-gallery
pnpm dlx @work-rjkashyap/unified-ui add image-gallery
npx @work-rjkashyap/unified-ui add image-gallery
bunx @work-rjkashyap/unified-ui add image-gallery

If 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-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

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

PropTypeDefaultDescription
imagesGalleryImage[]Array of images to display.
columns1 | 2 | 3 | 43Number of grid columns.
gapnumber8Gap between grid items in pixels.
aspectRatio"square" | "video" | "auto""square"Aspect ratio for thumbnails.
lightboxbooleantrueWhether to enable the lightbox on click.
classNamestringAdditional CSS classes on the grid.
renderThumbnail(image, index) => ReactNodeCustom thumbnail renderer.

GalleryImage

PropertyTypeDescription
srcstringImage source URL.
altstringAlt text for accessibility.
thumbnailstringOptional thumbnail URL (falls back to src).
captionstringOptional caption shown in lightbox.

Keyboard Navigation

KeyAction
/ Previous / Next image
EscapeClose lightbox
Click imageToggle zoom

Accessibility

  • Grid uses role="group" with aria-label.
  • Lightbox uses role="dialog" with aria-modal.
  • All images require alt text for screen readers.
  • Full keyboard navigation support in lightbox.
  • Thumbnail strip buttons use aria-current for 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

TokenUsage
--borderThumbnail border
--mutedThumbnail background
--radius-lgThumbnail border radius
--shadow-mdHover shadow on thumbnails
--duration-fastTransition speed

On this page