InteractionKit

ImageViewer

Expand an image into a focused, gesture-friendly viewer.

Preview

Usage

image-viewer.tsx
import "useintkit/styles.css";
import { ImageViewer } from "useintkit";

<ImageViewer
  src="/images/coast.jpg"
  alt="A quiet coastline"
  caption="An afternoon by the sea"
/>

Image gallery

Show one to four images in a responsive grid. Each image opens in the viewer. ImageGallery is available in useintkit@0.0.1 and later.

image-gallery.tsx
import { ImageGallery } from "useintkit";

<ImageGallery
  images={[
    { src: "/images/coast.jpg", alt: "A quiet coastline" },
    { src: "/images/mountain.jpg", alt: "A mountain view" },
  ]}
  style={{ maxWidth: 480, maxHeight: 400 }}
/>

Set the gallery’s width, height, and maximum dimensions with its style or className. Use --ik-image-max-width and --ik-image-max-height to limit expanded images.

Props

PropTypeDescription
srcstringRequired. Full-size image URL.
altstringRequired. Descriptive alternative text.
thumbnailSrcstringOptional thumbnail URL; defaults to src.
captionReactNodeOptional content beneath the expanded image.
open / onOpenChangeboolean / functionControl the viewer from your application.
defaultOpenbooleanInitial state when uncontrolled.

Escape, the backdrop, the close button, or a deliberate drag dismisses the viewer. Focus returns to the trigger.