Clinia UI

Avatar

Shows a user or an organization as an image, with initials when there is none.

shadcn docs →

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 AvatarGroup and 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/avatar
FLJCFMRR

Anatomy

ATJCML
+4
  1. 1Groupdata-slot="avatar-group"-space-x-1 · ring-background
  2. 2Avatardata-slot="avatar"size-8 · rounded-full · border-border
  3. 3Fallbackdata-slot="avatar-fallback"bg-muted · text-muted-foreground
  4. 4Countdata-slot="avatar-group-count"bg-muted · text-sm

Clinia rules

  • Sizes are sm (24px), default (32px) and lg (40px). Keep one size per list.
  • The fallback is two initials on bg-muted in text-muted-foreground.
  • The edge is the border hairline, drawn over the image so it holds on photos in both themes.
  • AvatarBadge is a small primary dot. Say what it means in text: the dot alone doesn't.

Do and don't

AT
Do show initials when there is no photo.
Don't leave an empty circle when the photo fails to load.
ATDr. Amélie Tremblay
Do put the name next to the avatar.
AT
Don't make users guess who the initials belong to.

States

sizes sm / default / lg
JCJCJC
with badge
JC
group
JCFMRR
+4

Toggle the site theme to review both themes.

Accessibility

Built in

  • AvatarImage renders only once the image has loaded. Until then, or if it fails, AvatarFallback shows.

Your responsibility

  • Write alt as the user's name. When the name is already next to the avatar, use alt="" so it isn't read twice.
  • Put an AvatarFallback beside every AvatarImage, so something still shows if the image fails to load.
  • Give AvatarGroupCount an aria-label such as 4 more clinicians. +4 alone reads poorly.
  • Say what an AvatarBadge means in visible or sr-only text.

How to test

  1. Point AvatarImage at a broken URL: the initials show in its place.
  2. With a screen reader, an avatar next to a name is read once, not twice.
  3. Toggle the site theme: the edge and the initials stay visible in both.

API

PropValuesDefaultDescription
size
defaultsmlg
default

sm 24px, default 32px, lg 40px.

All other props come from Base UI Avatar.