Avatar
avatarA user image with a fallback that shows initials while the image loads, and when it never arrives at all. Built on the Base UI avatar primitive, so the image and the fallback swap without a flash of empty space.
import { Avatar, AvatarFallback, AvatarImage, avatarInitials } from "@/components/forme/avatar/avatar";
// Inline so the demo works offline: a real photo would be an unhandled request.
const portrait =
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='lightgray'/%3E%3Ccircle cx='32' cy='24' r='11' fill='silver'/%3E%3Cpath d='M8 64a24 24 0 0 1 48 0z' fill='silver'/%3E%3C/svg%3E";
export function AvatarDemo() {
return (
<div className="flex flex-col gap-8">
<div className="flex flex-wrap items-center gap-4">
<Avatar>
<AvatarImage src={portrait} alt="" />
<AvatarFallback>{avatarInitials("Francesca Rossi")}</AvatarFallback>
</Avatar>
{/* A missing image is the common case, not an edge case: the fallback is
what most avatars show most of the time. */}
<Avatar>
<AvatarImage src="/avatar-does-not-exist.png" alt="" />
<AvatarFallback>{avatarInitials("Ada Lovelace")}</AvatarFallback>
</Avatar>
<Avatar>
<AvatarFallback>{avatarInitials("Grace Hopper")}</AvatarFallback>
</Avatar>
</div>
<div className="flex flex-wrap items-end gap-4">
<Avatar size="sm">
<AvatarFallback>{avatarInitials("Lin Chen")}</AvatarFallback>
</Avatar>
<Avatar size="md">
<AvatarImage src={portrait} alt="" />
<AvatarFallback>{avatarInitials("Lin Chen")}</AvatarFallback>
</Avatar>
<Avatar size="lg">
<AvatarFallback>{avatarInitials("Lin Chen")}</AvatarFallback>
</Avatar>
</div>
<div className="flex flex-wrap items-center gap-3">
<Avatar>
<AvatarImage src={portrait} alt="" />
<AvatarFallback>{avatarInitials("Lin Chen")}</AvatarFallback>
</Avatar>
<div className="grid text-body-regular">
<span className="font-medium">Lin Chen</span>
<span className="text-muted-foreground">lin@company.com</span>
</div>
</div>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'md' | 'lg' | 'sm' | "md" |
Also takes every prop of Base UI Avatar.Root.
The other parts
AvatarImageTakes Base UIAvatar.ImageAvatarFallbackTakes Base UIAvatar.Fallback
Related


Area Chart
A line or area chart in plain SVG with no chart library. A crosshair snaps to the nearest point and lists every series, arrow keys walk it, round tick values, a legend from two series up, and a hidden table so screen readers get the numbers.
data display

Badge
A small label for status, counts and metadata, in five quiet variants and two sizes. The colour lives in the tint so the text stays readable at eleven pixels, and an icon or a dot inside the badge carries the state at a glance.
data display

Bar Chart
A single or grouped column chart in plain SVG. Columns are capped at 24px with rounded tops and 2px gaps, the hovered category lifts while the rest recede, arrow keys read each category, and a hidden table carries every value.
data display