npx shadcn@latest add https://sdk-components.thesqd.com/r/avatar.jsonimport { Avatar } from "@/components/ui/avatar";import { Avatar } from "@/components/ui/avatar";
export function Example() {
// Either src or name is required; with neither, a UserIcon shows.
return <Avatar name="Sarah Hill" />;
}Avatar — single element, prop-driven
├── src — image URL (rendered when set)
├── name — generates the initials fallback + a deterministic brand color
├── initials — explicit initials override (defaults to those from name)
├── color — explicit brand color override (defaults to one from name)
├── alt — accessible label
├── size — xs · sm · md · lg · xl · 2xl … 9xl (default: md)
├── isSquare — rounded-square instead of circle (default: false)
├── caption — renders the avatar beside its name label + this caption
└── people[] — { name?, src?, initials?, alt? }: one → single avatar,
many → overlapping cluster (cap with max → "+N")
With no src and no name, a neutral UserIcon placeholder renders.| Prop | Type | Default | Description |
|---|---|---|---|
src | string | null | null | Image URL. Takes precedence over the name/initials fallback. |
name | string | — | Generates the initials fallback and a deterministic brand color. |
initials | string | — | Explicit initials, overriding those derived from `name`. |
color | AvatarColor | — | Pin a brand color (brand, indigo, coral, purple, amber, magenta, lavender, lilac, pink, cream, blush, peach) instead of the auto one. |
caption | ReactNode | — | Render the avatar beside its `name` label and this caption line. |
people | { name?, src?, initials?, alt? }[] | — | Group mode — one entry renders a single avatar; multiple render an overlapping cluster. |
max | number | — | Cap the visible avatars in a `people` group; the rest collapse into a `+N` chip. |
alt | string | — | Accessible label for the image / fallback. |
size | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" … "9xl" | "md" | Diameter via a CSS variable. Range from 20px (xs) to 168px (9xl). |
isSquare | boolean | false | Rounded square instead of a circle. |
className | string | — | Extra classes on the avatar (or the group wrapper in `people` mode). |