Components
An image element with a fallback for representing the user.
Playground
Avatar from an AvatarImage and an AvatarFallback — the fallback renders while the image loads and whenever it fails. An optional AvatarBadge pins a status indicator to the bottom end of the avatar.import {
Avatar,
AvatarBadge,
AvatarFallback,
AvatarGroup,
AvatarGroupCount,
AvatarImage,
} from "@workspace/ui/components/avatar"
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>AvatarFallback takes its place — use initials or an icon. Pass delayMs to avoid a flash of the fallback on fast connections.<Avatar>
<AvatarImage src="/broken-image.jpg" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<Avatar>
<AvatarFallback delayMs={600}>
<UserIcon className="size-4" />
</AvatarFallback>
</Avatar>size prop to switch between sm (24px), default (32px) and lg (40px). The fallback text and badge scale along via data-size group selectors.<Avatar size="sm"> <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" /> <AvatarFallback>CN</AvatarFallback> </Avatar> <Avatar> <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" /> <AvatarFallback>CN</AvatarFallback> </Avatar> <Avatar size="lg"> <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" /> <AvatarFallback>CN</AvatarFallback> </Avatar>
AvatarBadge renders a status dot ringed with the background color. It defaults to bg-primary — override it with a token class like bg-destructive, and drop an icon inside on larger sizes (it is hidden on sm).<Avatar size="sm">
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
<AvatarBadge />
</Avatar>
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
<AvatarBadge className="bg-destructive" />
</Avatar>
<Avatar size="lg">
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
<AvatarBadge>
<CheckIcon />
</AvatarBadge>
</Avatar>AvatarGroup to overlap them — each avatar gains a ring-background separator so the stack stays readable over any surface.<AvatarGroup>
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<Avatar>
<AvatarImage src="https://github.com/vercel.png" alt="@vercel" />
<AvatarFallback>VC</AvatarFallback>
</Avatar>
<Avatar>
<AvatarImage src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<AvatarFallback>ER</AvatarFallback>
</Avatar>
</AvatarGroup>AvatarGroupCount to summarize the remaining members — it accepts text or an icon and tracks the group size automatically via group-has-data-[size=*] selectors.<AvatarGroup>
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<Avatar>
<AvatarImage src="https://github.com/vercel.png" alt="@vercel" />
<AvatarFallback>VC</AvatarFallback>
</Avatar>
<AvatarGroupCount>+3</AvatarGroupCount>
</AvatarGroup>
<AvatarGroup>
{/* ... */}
<AvatarGroupCount>
<PlusIcon />
</AvatarGroupCount>
</AvatarGroup>DropdownMenu for account menus — wrap it in a Button with size="icon" so it gets focus and hover treatment.<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" className="rounded-full">
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Profile</DropdownMenuItem>
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Log out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>dir="rtl" on a wrapper or inherit it from a Direction provider — the AvatarBadge is pinned with end-0, so it flips to the bottom left automatically, and grouped avatars overlap in the opposite direction.<div dir="rtl" className="flex items-center gap-4">
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
<AvatarBadge />
</Avatar>
<AvatarGroup>
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<Avatar>
<AvatarImage src="https://github.com/vercel.png" alt="@vercel" />
<AvatarFallback>VC</AvatarFallback>
</Avatar>
<AvatarGroupCount>+3</AvatarGroupCount>
</AvatarGroup>
</div>Avatar, AvatarImage and AvatarFallback wrap the Radix Avatar primitives and accept all of their props. AvatarBadge, AvatarGroup and AvatarGroupCount render plain elements and accept the matching HTML props.| Prop | Type | Default |
|---|---|---|
| Avatar size | "default" | "sm" | "lg" | "default" |
| AvatarImage src / alt | string | — |
| AvatarFallback delayMs | number | 0 |
| className (all parts) | string | — |
Tokens used
9 design tokens consumed by the Avatar component.
--border
Border
--muted
Muted
--muted-foreground
Muted Foreground
--primary
Primary
--primary-foreground
Primary Foreground
--background
Background
--text-sm
Text Small (14px)
--text-xs
Text Extra Small (12px)
--spacing
Spacing unit (4px)