Skip to content
Component installs need the registry setup
VegaStack Design

Avatar

An image element with a fallback for representing a user — plus a status badge, three sizes, and an overlapping group.

Status
stable
Since
0.1.0
Accessibility pattern
img with alt, decorative badge

Last updated

ALLT
ALLTGH
+3

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 avatar

Install with the pinned shadcn CLI. Bare shadcn does not verify VegaStack signature or integrity.

pnpm dlx shadcn@4.21.0 add @vegastack/avatar

Run 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>;
ALLT
ALLTGH
+3

Anatomy

Avatar — data-slot="avatar"
AvatarBadge — data-slot="avatar-badge"
AvatarFallback — data-slot="avatar-fallback"
AvatarGroup — data-slot="avatar-group"
AvatarGroupCount — data-slot="avatar-group-count"
AvatarImage — data-slot="avatar-image"

Examples

Composition

Avatar wraps an AvatarImage, an AvatarFallback and an optional AvatarBadge. AvatarGroup wraps a run of Avatars and an optional trailing AvatarGroupCount.

GH
ALLT
+8

Basic

A basic avatar with an image and a fallback.

AL

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.

AL

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.

GH

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.

ALLTGH

Avatar Group Count

Use AvatarGroupCount to close the stack with a count. It tracks the group's avatar size.

ALLTGH
+3

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.

ALLTGH
Add a teammate

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.

ALALAL

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.

AL
LTGH
+3
AL
LTGH
+٣

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.

ARBKCMDSEOFNGPHLITJWNA

API Reference

PropTypeDefaultDescription
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).

PropTypeDefaultDescription
hueAvatarHue—

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

  • AvatarImage renders a native <img>. Give it an alt naming the person; use alt="" when the avatar sits beside their name and would only repeat it.
  • AvatarFallback paints 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.
  • AvatarBadge is 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 Button and name the button.
ContractStates tested
Behaviourdefault, error, loading, selected
Accessibilitynative-or-base-ui-semantics, browser-accessibility-test
Visualdefault, loading, error

Do / Don't

Do
Give AvatarImage an alt that names the person, and keep initials in AvatarFallback.
Don't
Attach a click handler to Avatar itself — wrap it in a Button so it is focusable and named.

Deviations

Upstream's file plus packages/ui/upstream/patches/avatar.patch. Every hunk:

  • DOC-2 — cn is imported from @vegastack/design, and the file carries the registry provenance header.
  • TYP-14 — AvatarFallback uses text-xs at all three sizes while preserving upstream's public size API and diameters. The decision and approval provenance are recorded in docs/plans/2026-09-18-regent-avatar-148.md.
  • API-32 — AvatarFallback takes an optional hue (the ten --tag-* hues, exported as AvatarHue) painting bg-tag-{hue}-subtle text-tag-{hue}-text and writing data-hue; with no hue it keeps upstream's muted fallback.

On this page