Genesis
@beta

UserAvatar

UserAvatar — canonical user-identity avatar. Shows the person's photo when `src` is set and loads successfully; otherwise (including a failed image load — Radix's Avatar swaps to the fallback automatically) it falls back to initials computed from `name`. Wraps the lower-level `Avatar`/`AvatarImage`/`AvatarFallback` primitives so call sites stop hand-rolling initials logic per-usage. The root carries `role="img"` + `aria-label={name}` so the person's full name is the accessible name on BOTH paths — without it the fallback route renders a bare `span`, a generic element whose author-supplied label AT may ignore, announcing only the visible initials ("AL").

packages/ui/src/components/patterns/user-avatar.tsx

Import
Subpath export: @marktiderman/genesis-ui/patterns
import { UserAvatar } from "@marktiderman/genesis-ui/patterns";
Components
Auto-generated from TypeScript source via react-docgen-typescript.

UserAvatar

UserAvatar — canonical user-identity avatar. Shows the person's photo when `src` is set and loads successfully; otherwise (including a failed image load — Radix's Avatar swaps to the fallback automatically) it falls back to initials computed from `name`. Wraps the lower-level `Avatar`/`AvatarImage`/`AvatarFallback` primitives so call sites stop hand-rolling initials logic per-usage. The root carries `role="img"` + `aria-label={name}` so the person's full name is the accessible name on BOTH paths — without it the fallback route renders a bare `span`, a generic element whose author-supplied label AT may ignore, announcing only the visible initials ("AL").

PropTypeDefaultDescription
name*string—Full display name. Source for the computed initials fallback and the accessible name.
classNamestring—
distinctboolean—Tell people apart in a list of them (a feed): the initials fallback gets a stable tint per name, and a one-word name shows two letters ("Pr", "Po") instead of one.
size"sm" | "default" | "lg" | null—
srcstring | null—Image URL. Omit — or let it fail to load — to show the initials fallback.
testIDstring—Stable test/automation selector (emitted as `data-testid`).

DISTINCT_AVATAR_TINTS

Tints for `distinct` avatars: a light wash of a chart colour behind the foreground text. The chart colours themselves fail contrast as text (1.5 to 2.8 to 1 in the light theme), so the text stays `text-foreground`, which measures 14:1 or more on every wash in both themes.

No declared props.

Storybook
Storybook hosts the canonical visual reference with controls for every variant.