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 hasrole="img"labelled byalt. - Initials and icons inside the fallback are
aria-hidden. Avatar.Badgeis decorative — include status (e.g. "online") inalt.Avatar.OverlaywithonClickis a focusable button and needsaria-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.
| Prop | Type | Default | Description |
|---|---|---|---|
| alt (required) | string | — | Text alternative. Pass `""` for decorative images. |
| className | string | — | |
| crossOrigin | CrossOrigin | — | |
| fallbackIcon | ReactNode | — | Icon shown when there is no image and no `initials`. |
| filter | Filter | — | |
| gradientColor | AvatarGradient | — | 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. |
| initials | string | — | Shown when there is no image or it fails. Takes precedence over `fallbackIcon`. |
| loading | "eager" | "lazy" | — | |
| noBorder | boolean | — | Hide the thin inner border. |
| objectFit | ObjectFit | — | |
| objectPosition | ObjectPosition<string | number> | — | |
| onError | (() => void) | — | |
| onLoad | (() => void) | — | |
| referrerPolicy | HTMLAttributeReferrerPolicy | — | |
| size | number | 48 | Diameter in px (16–96 design sizes, or any number). |
| sizes | string | — | |
| src | string | — | |
| srcSet | string | — | |
| withTransparentBackground | boolean | — | 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`.
| Prop | Type | Default | Description |
|---|---|---|---|
| background | "stroke" | "shadow" | "stroke" | `stroke` cuts the badge out with a background-colored ring; `shadow` lifts it. |
| className | string | — |