Avatar
An image element with a fallback for representing a user — plus a status badge, three sizes, and an overlapping group.
- Status
- Since
0.1.0- Accessibility pattern
- img with alt, decorative badge
Last updated
Install
Configure registry credentials first using the Quickstart. Before copying this item or any transitive registry dependency, verify the signed manifest and save the exact bytes for Avatar before installation. Retain the digest printed by this command.
pnpm exec vegastack-design verify avatarInstall with the pinned shadcn CLI. Bare shadcn does not verify VegaStack signature or integrity.
pnpm dlx shadcn@4.21.0 add @vegastack/avatarRun the exact offline --post-write command printed by the preflight, using its saved item path and independently retained --expected-integrity digest. Use the saved preflight for every transitive registry dependency too; stop on any mismatch before using the components.
Usage
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
<Avatar>
<AvatarImage src="/team/ada.png" alt="Ada Lovelace" />
<AvatarFallback>AL</AvatarFallback>
</Avatar>;Anatomy
Examples
Composition
Avatar wraps an AvatarImage, an AvatarFallback and an optional AvatarBadge. AvatarGroup
wraps a run of Avatars and an optional trailing AvatarGroupCount.
Basic
A basic avatar with an image and a fallback.
Badge
Use AvatarBadge to add a badge to the avatar. It is positioned at the bottom end corner and sized
from the avatar's own size. Pass a className for a custom fill — here the success token.
Badge with Icon
An icon can go inside AvatarBadge. At size="sm" the icon is hidden, because the badge is too
small to carry one.
Avatar Group
Use AvatarGroup to overlap a run of avatars. Each child picks up a background-colored ring so the
stack reads as separate faces.
Avatar Group Count
Use AvatarGroupCount to close the stack with a count. It tracks the group's avatar size.
Avatar Group with Icon
AvatarGroupCount also takes an icon — an "add a teammate" affordance at the end of the stack.
Give it an accessible name, since an icon alone has no text.
Sizes
Use the size prop to change the avatar diameter: sm is 24px, default is 32px and lg is
40px. Fallback initials use text-xs at every size so they remain visually secondary to the person
or entity the avatar represents.
Dropdown
An avatar is a common dropdown trigger. Render the trigger as a Button and put the Avatar
inside it, so the control — not the image — owns the focus and the accessible name.
RTL
The badge is placed with end-0, so a right-to-left document moves it to the bottom left and
mirrors the group's overlap without any extra work.
Hues
AvatarFallback takes a hue — one of the ten tag hues (AvatarHue) — and paints the initials in
that hue's ink on its subtle fill: a person's own colour, so people are told apart before any photo
exists. Without a hue the fallback stays muted. For a person, compose PersonAvatar, which reads the
hue, the photo and the initials from one Person.
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "lg" | "sm" | — |
AvatarImage adds no props of its own — it accepts everything the underlying element or Base UI primitive accepts (className, ref, ARIA attributes, event handlers).
| Prop | Type | Default | Description |
|---|---|---|---|
hue | AvatarHue | — |
AvatarBadge adds no props of its own — it accepts everything the underlying element or Base UI primitive accepts (className, ref, ARIA attributes, event handlers).
AvatarGroup adds no props of its own — it accepts everything the underlying element or Base UI primitive accepts (className, ref, ARIA attributes, event handlers).
AvatarGroupCount adds no props of its own — it accepts everything the underlying element or Base UI primitive accepts (className, ref, ARIA attributes, event handlers).
Accessibility
AvatarImagerenders a native<img>. Give it analtnaming the person; usealt=""when the avatar sits beside their name and would only repeat it.AvatarFallbackpaints when the image has not loaded or has failed. Initials are text, so they are read out; an icon fallback is decorative and needs a name on whatever wraps it.AvatarBadgeis a decorative dot. A status it encodes — online, verified — must also exist as text somewhere a screen reader can reach.- An avatar is not a control. When it acts as one, wrap it in a
Buttonand name the button.
| Contract | States tested |
|---|---|
| Behaviour | default, error, loading, selected |
| Accessibility | native-or-base-ui-semantics, browser-accessibility-test |
| Visual | default, loading, error |
Do / Don't
Deviations
Upstream's file plus packages/ui/upstream/patches/avatar.patch. Every hunk:
- DOC-2 —
cnis imported from@vegastack/design, and the file carries the registry provenance header. - TYP-14 —
AvatarFallbackusestext-xsat all three sizes while preserving upstream's public size API and diameters. The decision and approval provenance are recorded indocs/plans/2026-09-18-regent-avatar-148.md. - API-32 —
AvatarFallbacktakes an optionalhue(the ten--tag-*hues, exported asAvatarHue) paintingbg-tag-{hue}-subtle text-tag-{hue}-textand writingdata-hue; with no hue it keeps upstream's muted fallback.