Avatar
Avatar with image loading, auto-initials fallback, five sizes, and grouping.
DKDKDKALGH
Install
npx shadcn@latest add https://plinth.dhrumilkherde.com/r/avatar.jsonUsage
If the image fails or is missing, the fallback renders; by default it derives
initials from alt.
import { Avatar, AvatarGroup } from "@/components/ui/avatar";
<Avatar src={user.photo} alt={user.name} size="sm" />
<Avatar alt="Dhrumil Kherde" /> {/* renders DK */}
<Avatar fallback={<IconUser />} alt="" /> {/* custom fallback */}Group
max collapses the rest into a +N counter.
ABCDEF+2
Props
| Prop | Type | Default |
|---|---|---|
size | xs · sm · md · lg · xl | md |
src | string | — |
alt | string | — |
fallback | ReactNode | initials from alt |
AvatarGroup: max?: number, size (applied to the overflow counter).
Accessibility
- Base UI Avatar handles image load state; the fallback shows until the image is ready, so there's no flash of empty circle.
- Give
alta person's name; it doubles as the initials source and the image's alternative text.