Avatar
A person, team or bot at a glance. A photo when there is one; otherwise initials on a tint that stays the same for each name, so people are easy to tell apart in a busy list.
Install
npx shadcn@latest add @nelumbo/avatarImage and initials
Pass src and name: the initials show until the image loads, or if it fails (the last one points at a missing file). name is also what screen readers hear.
Colors
color="auto" picks a palette tint from the name, so each person keeps theirs everywhere. Or set one: brand, red, orange, amber, green, cyan, blue, purple, pink.
Sizes and shapes
xs 24, sm 32, default 40, lg 56, xl 80. shape="rounded" for teams, projects and bots.
Status
AvatarBadge cuts a status dot out of the avatar's corner: online, away, busy or offline, spoken as such. Or put a small icon in it. On a card, set --avatar-ring to the card color.
Group
AvatarGroup overlaps avatars, each cut out with a ring, and folds the rest into "+N". The size passes down to every avatar.
Usage
import { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarImage } from "@/components/ui/avatar"<Avatar src={user.photo} name={user.name} color="auto" />// shadcn style<Avatar size="lg"> <AvatarImage src={user.photo} alt={user.name} /> <AvatarFallback>MK</AvatarFallback> <AvatarBadge status="online" /></Avatar><AvatarGroup max={4} aria-label="Project members"> {members.map((m) => <Avatar key={m.id} src={m.photo} name={m.name} color="auto" />)}</AvatarGroup>Props
| Prop | Type | Default | Set --avatar-ring on a parent to match the surface behind badges and groups (it defaults to the page background). |
|---|---|---|---|
name | string | Initials, the auto color and the accessible name | |
src | string | Image URL, when you don't pass children | |
size | "xs" | "sm" | "default" | "lg" | "xl" | "default" | 24, 32, 40, 56 or 80px |
shape | "circle" | "rounded" | "circle" | |
color | "neutral" | "auto" | palette color | "neutral" | The initials' tint; auto picks one from the name |
AvatarBadge status | "online" | "away" | "busy" | "offline" | Or children for an icon | |
AvatarGroup max | number | The rest fold into +N | |
AvatarGroup size / shape | Passed down to each avatar |