Skip to content

Avatar

Visual representation of a user or entity via image, initials, or fallback icon.

  • stable
  • since v0.1.0
  • 1.56 kB
  • feedback
  • identity
  • user

Renders an accessible image with alt text derived from name; falls back to initials or a labelled fallback when no image is available. Status dots are decorative (aria-hidden) — pair them with a textual label when status conveys meaning.

Preview
Open
tsx

Provide an src to render an <img>. When the image fails or is still loading, Avatar gracefully falls back to initials derived from name.

Preview
Open
tsx

Avatar ships six sizes — xs, sm, md (default), lg, xl, and 2xl.

Preview
Open
tsx

Pick between circle (default), rounded, and square shapes.

Preview
Open
tsx

When src is missing, Avatar shows the initials derived from name. A deterministic colour from the built-in palette is auto-selected per name; override with colorScheme (red, amber, green, blue, violet, pink, teal, orange).

Preview
Open
tsx

Pass status (online, offline, away, busy) to render a presence dot. Use statusPosition to anchor it to bottom-right (default) or top-right.

Preview
Open
tsx

Set ring to add a tokenised ring around the avatar — useful for stacked groups or highlighting the current user.

Preview
Open
tsx
PropTypeDefaultDescription
src
string
—
Image source URL. When omitted or failed to load, the fallback renders.
name
string
—
User's display name, used to derive initials and a deterministic colour.
alt
string
—
`alt` text for the image; falls back to `name`.
fallback
ReactNode
—
Custom fallback node rendered when the image is unavailable.
icon
ReactNode
—
Icon shown when neither image nor initials are available.
size
"xs"|"sm"|"md"|"lg"|"xl"|"2xl"
"md"
Pixel scale. One of `xs`, `sm`, `md`, `lg`, `xl`, `2xl`.
shape
"circle"|"square"|"rounded"
"circle"
Outline shape. One of `circle`, `square`, `rounded`.
colorScheme
"red"|"amber"|"green"|"blue"|"violet"|"pink"|"teal"|"orange"
—
Palette token for the fallback background. When omitted, a colour is derived deterministically from `name`.
status
"online"|"offline"|"away"|"busy"
—
Presence indicator. One of `online`, `offline`, `away`, `busy`.
statusPosition
"top-right"|"bottom-right"
"bottom-right"
Where the presence dot sits relative to the avatar.
ring
boolean
false
Render a halo ring around the avatar; useful for stacking in groups.
initials
string
—
Overrides the initials derived from `name`.
  • Provide a name so initials and alt text stay meaningful when the image is missing.
  • When the avatar is purely decorative, leave name empty and add aria-hidden="true" on the wrapping element.
  • Status dots render with aria-hidden="true" — pair them with an off-screen label or adjacent text when status conveys meaning.
  • The fallback waits 400ms before swapping in initials so users on fast networks see the image first.
  • Initials are rendered inside a fallback element which exposes an aria-label when only a name (no derived initials) is available.
  • Combine src with name so initials are ready as a graceful fallback.
  • Use ring on the current user’s avatar to disambiguate them in a roster.
  • Override colorScheme only when brand colour matters — the deterministic palette keeps an avatar’s colour stable across renders.
  • Compose multiple avatars inside <AvatarGroup> to represent collaborators with optional overflow.