Data Display

Image

Image viewer with zoom-on-hover preview, fallback, a responsive grid layout, and a fullscreen lightbox with keyboard navigation.

Single image with zoom preview

Mountain landscape
Ocean view

Grid — click to open lightbox

Mountain landscape
Ocean view
Forest path
City skyline
Desert dunes
Snowy peaks

Installation

npx benflux-ui add image

Usage

import { Image, ImageGrid, ImageLightbox } from "@benflux-ui/react"

// Single image with zoom preview on hover
<Image src="/photo.jpg" alt="Photo" width={300} height={200} preview />

// Responsive grid
<ImageGrid
  images={photos}
  columns={3}
  gap={8}
  onImageClick={(img, index) => setLightboxIndex(index)}
/>

// Fullscreen lightbox (keyboard: arrows + Esc)
{open && (
  <ImageLightbox
    images={photos}
    initialIndex={lightboxIndex}
    onClose={() => setOpen(false)}
  />
)}

Props — Image

PropTypeDefaultDescription
src*stringImage source URL
alt*stringAccessible alt text
widthnumberDisplay width in pixels
heightnumberDisplay height in pixels
previewbooleanfalseShow zoom icon on hover and open lightbox on click
fallbackstringFallback URL if the image fails to load

Props — ImageGrid

PropTypeDefaultDescription
images*{ src: string; alt: string; width?: number; height?: number }[]Array of image objects
columnsnumber3Number of grid columns
gapnumber8Gap between images in pixels
onImageClick(image: object, index: number) => voidCalled when an image is clicked