Image Gallery

A grid of thumbnails that open a viewer with previous and next.
Stable
Web
iOS
Android
@advui/core
Source

Basic

Installation

pnpm
pnpm add @advui/core
npm
npm install @advui/core

Usage

import { ImageGallery } from '@advui/core'

<ImageGallery
  images={[{ src: photo.url, thumbnail: photo.thumbUrl, alt: 'Clinic entrance', caption: 'Opened in June' }]}
/>

API reference

ImageGallery

PropTypeDefaultDescription
images requiredGalleryImage[]—`{ src, alt, caption?, thumbnail? }`. `alt` is required.
columnsnumberor a breakpoint map{ base: 2, sm: 3 }Thumbnails per row, mobile first.
rationumber1Thumbnail shape (width / height).
indexnumber | null—The image open in the viewer; `null` when closed.
defaultIndexnumber | null—Starting `index` when uncontrolled.
onIndexChange(index: number | null) => void—Called with the new `index`.
labelsPartial<ImageGalleryLabels>—Button names and "3 of 12", for translation.

Accessibility

  • Each thumbnail is a button named "View {alt}"; the thumbnail picture inside is decorative.
  • The viewer is a modal dialog titled with the image’s alt; the image keeps its alt, the caption describes the dialog, and "2 of 6" is a polite live region.
  • Previous and next are named buttons, disabled at the ends; focus returns to the thumbnail on close.
Keyboard interactions
KeyAction
Enter / SpaceOpens the focused thumbnail.
Arrow Left / Arrow RightPrevious or next image (web).
EscapeCloses the viewer.

Responsive behavior

The grid follows columns; the viewer fits the screen and keeps the image’s shape.

Platform notes

Web
Pass smaller thumbnail URLs so the grid loads fast.
iOS
Swipe is not wired; use the previous and next buttons.
Android
Same as iOS; the back button closes the viewer.
Since v0.6.0Last updated Nov 2, 2026Edit this page on GitHub