Avatar
Represents a user with an image, initials fallback, and optional presence status. Multi-part over Radix Avatar; size and shape flow to every part through Context.
Installation#
Usage#
import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"
export function Example() {
return (
<Avatar>
<AvatarImage src="/jordi.jpg" alt="Jordi Espinosa" />
<AvatarFallback>JE</AvatarFallback>
</Avatar>
)
}Anatomy#
import {
Avatar,
AvatarImage,
AvatarFallback,
AvatarStatus,
AvatarBadge,
} from "@/components/ui/avatar"
<Avatar>
<AvatarImage />
<AvatarFallback />
<AvatarStatus />
<AvatarBadge />
</Avatar>Sizes#
Five fixed sizes, from xs (24px) to xl (64px). The status dot and fallback text scale with the box.
Shape#
Circular by default; set shape="square" for a rounded-square avatar (e.g. organizations).
Fallback#
When no image is provided or it fails to load, Radix shows the fallback. Use delayMs to avoid a flash while a valid image loads.
The fallback adapts to the box. A small avatar (xs/sm) shows a single initial so the glyph never crowds the silhouette; md and up show two. Pass the same two-letter string everywhere and let the size decide, or override per instance with maxInitials.
Color#
color tints the initials fallback with a soft background and strong text from a single categorical token - the same palette as the Badge hues, so it re-themes across all four themes. Use it to distribute initials across users, teams, or tags. It only paints the fallback; an image, when present, covers it.
Status#
AvatarStatus adds a presence dot that sits outside the silhouette and reuses the status tokens (online/away/busy/offline).
The position prop controls which corner the dot occupies - useful when another element (icon, badge) already occupies the default bottom-right corner.
Logo badge#
AvatarBadge is the same corner overlay as AvatarStatus, but it holds a brand or app mark instead of a presence dot. Drop an <img> or icon inside and it fits the coin, which carries a ring-background gap so it reads off the photo behind it. Use it to tag who someone is on another platform, an org badge, or a verified mark.
The coin's shape is its own, independent of the avatar: keep the round coin or set shape="square" for the classic app-icon look.
It scales with the avatar and takes the same position prop as the status dot, so you can move it off the default bottom-right corner.
Stack#
AvatarGroup stacks collaborators into one cluster. It owns the overlap, the ring-background separation, and the hover lift, so the children stay plain Avatars with no per-instance ring or z-index. Cap the visible count with max and the rest collapse into a +N chip; pass total when the real count exceeds the avatars you render. Match the group's size to its children; the overlap tightens as the box grows.
Reach for renderOverflow to swap the default chip for a richer affordance, like a Tooltip that names the people the stack hides. See the full API on the Avatar Group page.
Examples#
Common patterns where avatars appear in product UI - combined with other components.
API reference#
Avatar
The root, over Radix Avatar.Root (a <span>): forwards all its props, and its size and shape flow to every part. Also exported as AvatarRoot. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | 24, 32, 40, 48 or 64px. Also scales the status dot, the badge and the initials cap. |
| shape | "circle" | "square" | "circle" | The silhouette; the image and fallback inherit its radius. |
| color | "default" | "brand" | "purple" | "pink" | "teal" | "orange" | "default" | Tints the initials fallback only. An image covers it. |
AvatarImage
The photo, over Radix Avatar.Image (an <img> rendered once it loads). Forwards all its props.
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | - | The image URL. |
| alt | string | - | The person's name, for assistive tech. |
| onLoadingStatusChange | (status: "idle" | "loading" | "loaded" | "error") => void | - | Called as the image loads or fails. |
AvatarFallback
The initials or icon shown when there is no image or it fails, over Radix Avatar.Fallback. Forwards all its props.
| Prop | Type | Default | Description |
|---|---|---|---|
| maxInitials | number | 1 at xs and sm, 2 above | Caps how many characters of a string child render. Any other node renders as is. |
| delayMs | number | - | Waits before showing, to avoid a flash of initials while a valid image loads. |
AvatarStatus
A presence dot on a corner, ringed off the avatar. Forwards all native <span> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "online" | "away" | "busy" | "offline" | "online" | The dot color, from the status tokens. |
| position | "bottom-right" | "top-right" | "bottom-left" | "top-left" | "bottom-right" | The corner the dot sits on. |
AvatarBadge
A corner coin for a small logo or mark (an <img> or icon inside). Forwards all native <span> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| position | "bottom-right" | "top-right" | "bottom-left" | "top-left" | "bottom-right" | The corner the badge sits on. |
| shape | "circle" | "square" | "circle" | The coin shape, independent of the avatar's. |