datui
Color scheme

Data display

Avatar

Round image for a person or entity, with initials or icon fallback.

import { Avatar, AvatarBadge } from "datui";

Playground

<Avatar alt="Jane Doe" initials="JD" size={48} gradientColor="violet" />

Examples

Images and fallbacks

Accessibility

  • Loaded avatars render <img alt>; while loading or after an error the fallback has role="img" labelled by alt.
  • Initials and icons inside the fallback are aria-hidden.
  • Avatar.Badge is decorative — include status (e.g. "online") in alt.
  • Avatar.Overlay with onClick is a focusable button and needs aria-label; it is revealed on hover and focus.

API

Avatar

Round image for a person or entity. Falls back to `initials`, then `fallbackIcon`, while the image is missing, loading or broken. Accepts `Avatar.Badge` and `Avatar.Overlay` children.

PropTypeDefaultDescription
alt (required)string—Text alternative. Pass `""` for decorative images.
classNamestring—
crossOriginCrossOrigin—
fallbackIconReactNode—Icon shown when there is no image and no `initials`.
filterFilter—
gradientColorAvatarGradient—Background behind initials/icon. `1`–`6` map to the named gradients in order. `custom` reads `--dt-avatar-custom-from` / `--dt-avatar-custom-to` from your styles.
initialsstring—Shown when there is no image or it fails. Takes precedence over `fallbackIcon`.
loading"eager" | "lazy"—
noBorderboolean—Hide the thin inner border.
objectFitObjectFit—
objectPositionObjectPosition<string | number>—
onError(() => void)—
onLoad(() => void)—
referrerPolicyHTMLAttributeReferrerPolicy—
sizenumber48Diameter in px (16–96 design sizes, or any number).
sizesstring—
srcstring—
srcSetstring—
withTransparentBackgroundboolean—Drop the placeholder background (for transparent images).

AvatarBadge

Badge on the bottom-end edge of an `Avatar`. Without children it renders an "online" dot. Decorative — put status in `alt`.

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