Avatar
Avatar
A face, or initials until there is one: the photo rises out of a blur once it has loaded, and a stack of avatars fans open when you point at it.
Dependencies
React
Interaction states
- loading — Initials on a muted circle.
- loaded — The photo fades in from a 6px blur at 1.08 (360–520ms).
- group hover — The overlap opens to a 4px gap; +N rolls when it changes.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/avatarFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
components.json
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Team and member lists
A face, name and status in each row.
Comments and activity
Who said what, at 28px.
Shared documents
A stack of collaborators with +N.
Workspace switchers
Square avatars for teams.
What it handles
- No broken images — Initials first; the photo replaces them only once loaded, cached ones included.
- Presence — online, away, busy, offline as a dot with a background ring.
- Fanning stack — Hover spreads the group (380ms, 20ms stagger).
- Four sizes, two shapes — 20, 28, 36, 48px; circle or rounded square.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { Avatar, AvatarGroup } from "@/components/avatar";
<Avatar name="Ada Okafor" src="/ada.jpg" status="online" />
<AvatarGroup people={members} max={4} />Props
| Prop | Type | Description |
|---|---|---|
| name | string | – · Initials and the accessible name. |
| src | string | – · Photo URL. |
| size | "xs" | "sm" | "md" | "lg" | "md" · 20, 28, 36 or 48px. |
| status | "online" | "away" | "busy" | "offline" | – · Presence dot. |
| shape | "circle" | "square" | "circle" · Square for teams. |
| AvatarGroup | { people, max, size } | – · Overlapping stack with +N. |
Accessibility & motion
- role="img" with the name (and status) as its label. - Reduced motion: the photo fades without blur; the stack doesn't fan.
pnpm dlx shadcn@4.21.5 add @cavemio/avatar