Skip to content
Alea0.1

Data display

Image

Lazy images with a loading shimmer, a fallback, and a zoomable preview.

Ant Design: Image

import { Image } from '@alea/ui';

Examples

Image

Lazy, with a shimmer while loading. Press it for a zoomable preview.

Fallback

When an image can't load.

Responsive and fast

srcSet and sizes pick the right file, ratio reserves the space, priority loads the hero first, and a color placeholder fades into the image.

Props

Image props

An image that loads lazily, shows a shimmer while loading and a fallback on error, and opens a zoomable preview (Ant's Image).

PropTypeDefaultDescription
altrequiredstring-Describe the image; empty string only when it is decorative.
srcrequiredstring-The image URL.
classNamestring-Extra class names for the root element.
fallbackReactNode-Shown while loading and if it fails.
fit"none" | "inherit" | "fill" | "initial" | "-moz-initial" | "revert" | "revert-layer" | "unset" | "contain" | "cover" | "scale-down"'cover'CSS object-fit. Default cover.
heightstring | number-Height in px.
placeholderstring-A tiny blurred version (data URL or color) shown until it loads; then the image fades in. Default the shimmer.
previewbooleantrueOpens a larger view with zoom on press. Default true.
priorityboolean-The main image of the page (LCP): loads right away with high priority instead of lazily.
radius"sm" | "md" | "lg" | "none"'md'Corner radius token: sm, md (default), lg or none.
rationumber-Width / height, e.g. 16 / 9: reserves the space so nothing jumps while it loads.
sizesstring-How wide it shows, for srcSet: "(min-width: 768px) 50vw, 100vw".
srcSetstring-Responsive sources: "hero-640.jpg 640w, hero-1280.jpg 1280w".
widthstring | number-Width in px.

Accessibility

  • alt is required; the preview button says what it opens.

Keyboard

KeyDoes
EnterOpens the preview
+ / -Zoom in the preview
EscapeCloses the preview

Do and don't

Do

  • Always write alt text that says what matters in the image.
  • Set width and height to avoid layout shift.

Don't

  • Don't put text in images.
  • Don't open a preview for decorative images.
Tested with axe, keyboard and screen reader roles