datui
Color scheme

Data display

Image

Rounded-rectangle thumbnail with fallback icon, badges, overlay and floating elements.

import { Image, ImageBadge, ImageOverlay, ImageFloatElement } from "datui";

Playground

<Image alt="Thumbnail" size={64} borderRadius="m" />

Examples

Images, fallback and parts

HD

Accessibility

  • Loaded images render <img alt>; the fallback has role="img" labelled by alt (none when alt="").
  • Image.Badge is decorative; Image.Overlay with onClick is a button and needs aria-label.
  • The hover overlay also appears on keyboard focus.

API

Image

Rounded-rectangle thumbnail with a fallback icon. Accepts `Image.Badge`, `Image.Overlay` and `Image.FloatElement` children.

PropTypeDefaultDescription
alt (required)string—Text alternative. Pass `""` for decorative images.
borderEndEndRadiusRadius—
borderEndStartRadiusRadius—
borderRadiusRadiusm
borderStartEndRadiusRadius—
borderStartStartRadiusRadius—
classNamestring—
crossOriginCrossOrigin—
fallbackIconReactNode—Icon shown when there is no image or it fails to load.
filterFilter—
heightSizestring | number—Height override (px number or CSS length).
keepAspectRatioboolean—Let the image's own aspect ratio set the height.
loading"eager" | "lazy"—
noBorderboolean—Hide the thin inner border.
objectFitObjectFit—
objectPositionObjectPosition<string | number>—
onError(() => void)—
onLoad(() => void)—
referrerPolicyHTMLAttributeReferrerPolicy—
sizenumber48Square size in px. Use `widthSize`/`heightSize` for other shapes.
sizesstring—
srcstring—
srcSetstring—
widthSizestring | number—Width override (px number or CSS length).
withTransparentBackgroundboolean—Drop the placeholder background (for transparent images).

ImageBadge

Small round badge pinned to the bottom-end corner of an `Image` or `Avatar`. Content is decorative.

PropTypeDefaultDescription
background"stroke" | "shadow"stroke`stroke` cuts the badge out with a background-colored ring; `shadow` lifts it.
classNamestring—

ImageOverlay

Layer over an `Image`/`Avatar`, e.g. an edit or play icon. With `onClick` it renders a button — give it an `aria-label`.

PropTypeDefaultDescription
classNamestring—
disabledboolean—
theme"light" | "dark"darkOverlay tint.
visibility"on-hover" | "always"on-hover`on-hover` reveals the overlay on hover/focus; `always` keeps it visible.

ImageFloatElement

Freely positioned element (e.g. a `ContentBadge` or `Counter`) pinned to a corner of an `Image`.

PropTypeDefaultDescription
classNamestring—
placement"top-start" | "bottom-start" | "top-end" | "bottom-end"top-endCorner to pin to.