Loading component…
Loading component…
A person's picture or initials on a soft color of their own – rounded squares for workspaces, an agent's pixel mark, a status dot and an overlapping group ending in +N
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Avatar from ./avatar.
import { Avatar, AvatarGroup } from "@/components/ui/avatar";
type Member = { id: string; name: string; picture?: string; online?: boolean };
export function Reviewers({ members }: { members: Member[] }) {
return (
<AvatarGroup size={24} max={4} aria-label={`${members.length} reviewers`}>
{members.map((m) => (
<Avatar key={m.id} seed={m.id} name={m.name} src={m.picture} status={m.online ? "online" : undefined} />
))}
<Avatar kind="agent" seed="triage" name="Triage agent" />
</AvatarGroup>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| name | string | Who it is – the initials (first and last word), the accessible name and the color come from it. Left out: a person outline on gray | |
| src | string | The picture. The initials show while it loads and stay when it fails to load | |
| size | 20 \| 24 \| 32 \| 40 | 32 | Width and height in pixels; the initials, the status dot and an agent's mark scale with it |
| shape | "circle" \| "square" | "circle" (agents: "square") | circle for people · square, a rounded square, for workspaces, teams and agents |
| status | "online" \| "away" \| "busy" | A green, amber or red dot on the corner – added to the accessible name, e.g. "Mara Lindqvist, online" | |
| kind | "person" \| "agent" | "person" | agent: the agent's own 3×3 pixel mark on a white tile instead of initials – never a monogram. A src still shows its logo |
| seed | string | name | What the color and an agent's pattern are made from – pass a stable id so a rename keeps them |
| color | string | blue | agent: the mark's color – use the same color the agent has elsewhere |
| working | boolean | agent: the squares twinkle in a diagonal wave while it works | |
| ...span props | ComponentProps<"span"> | className, style, title, aria-label, aria-hidden, ref and the rest go to the outer <span> | |
| AvatarGroup max | number | 4 | How many show before the rest becomes +N (99+ above 99) |
| AvatarGroup size | 20 \| 24 \| 32 \| 40 | 32 | Sets the size of every Avatar in it and of the +N |
| AvatarGroup total | number | How many there are in all, when you pass only the first few – +N counts from it |
Initials are whole characters (Intl.Segmenter): accents, emoji with skin tones and flags never split; a name that starts with an emoji shows just that emoji
"III", "Jr." and the like don't make an initial, nor do brackets or quotes in front of a word – "Christopher Montgomery III" is CM
Right-to-left: the status dot and the overlap mirror to the other side
The group's ring and the status ring use --ui-avt-ring – set it to the background the avatars sit on (white by default)
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.