Skip to content

Avatar

A person's image with initials fallback, sizes and groups.

Give AvatarFallback the person's name and it takes one of six tints, the same one wherever that name appears. The fallback shows until the image has loaded, and stays when there is no image or it fails.

Initials

IQPLAFTRWANF?

Sizes

xs
sm
default
row
lg

With an image

  • AFArlo Finch
  • TRTam Rook

With a badge

WAIQPL

Group

Installation

npx shadcn@latest add @khaeli/avatar

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items
npm packages
  • @base-ui/react ^1.7.0

Accessible name

  • Initials alone are read as letters. An avatar that stands for a person with no name written beside it takes role="img" and an aria-label with the name.
  • Beside the written name the avatar is decoration: hide it with aria-hidden, and give AvatarImage an empty alt.
  • AvatarImage always needs alt: the name when the avatar stands alone, empty when the name is beside it.
  • AvatarBadge has no text. Say what it means in the avatar's label: Wren Alder, online.
  • Name an AvatarGroup as one image that lists who is in it, or name each avatar. The text of AvatarGroupCount, such as +4, is read as written.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/avatar.json