Avatar
Shows a user or an organization as an image, with initials when there is none.
When to use
- Show who a user is next to their name: a clinician, a teammate, an assignee.
- Show a group of users compactly, with
AvatarGroupand a count.
When not to use
- A status or a category: use Badge.
- A content image, such as a clinic photo: use Aspect Ratio.
Install
npx shadcn@latest add @clinia/avatarFLJCFMRR
Anatomy
ATJCML
+4
- 1Group
data-slot="avatar-group"-space-x-1 · ring-background - 2Avatar
data-slot="avatar"size-8 · rounded-full · border-border - 3Fallback
data-slot="avatar-fallback"bg-muted · text-muted-foreground - 4Count
data-slot="avatar-group-count"bg-muted · text-sm
Clinia rules
- Sizes are
sm(24px),default(32px) andlg(40px). Keep one size per list. - The fallback is two initials on
bg-mutedintext-muted-foreground. - The edge is the
borderhairline, drawn over the image so it holds on photos in both themes. AvatarBadgeis a smallprimarydot. Say what it means in text: the dot alone doesn't.
Do and don't
AT
ATDr. Amélie Tremblay
AT
States
sizes sm / default / lg
JCJCJC
with badge
JC
group
JCFMRR
+4
Toggle the site theme to review both themes.
Accessibility
Built in
AvatarImagerenders only once the image has loaded. Until then, or if it fails,AvatarFallbackshows.
Your responsibility
- Write
altas the user's name. When the name is already next to the avatar, usealt=""so it isn't read twice. - Put an
AvatarFallbackbeside everyAvatarImage, so something still shows if the image fails to load. - Give
AvatarGroupCountanaria-labelsuch as4 more clinicians.+4alone reads poorly. - Say what an
AvatarBadgemeans in visible orsr-onlytext.
How to test
- Point
AvatarImageat a broken URL: the initials show in its place. - With a screen reader, an avatar next to a name is read once, not twice.
- Toggle the site theme: the edge and the initials stay visible in both.
API
| Prop | Values | Default | Description |
|---|---|---|---|
| size | defaultsmlg | default |
|
All other props come from Base UI Avatar.