Identity and Avatars

Fixed-size avatar primitives for initials, images, shape variants, and overlapping groups.

Avatars represent a person, team, or account in a compact visual region. Use <user-avatar>, [data-avatar], or .avatar; all three hosts share the same size, shape, image, and theming contract.

Sizes and host forms

The default avatar is 2.75rem. Use size="sm" for dense interfaces and size="lg" for prominent identity surfaces. Its inline and block dimensions are invariant, so a flex or grid parent cannot compress the circle into an oval.

Avatar sizes and public hosts

ALGHKJ
<user-avatar size="sm" aria-label="Ada Lovelace">AL</user-avatar>
<span data-avatar aria-label="Grace Hopper">GH</span>
<span class="avatar" size="lg" aria-label="Katherine Johnson">KJ</span>

Circle and square shapes

Circle is the default. shape="square" uses the shared medium radius while preserving the same square footprint.

Round and square avatars

RASO

Image and initials fallback

An img or picture child fills the avatar and uses object-fit: cover. Keep meaningful identity in the image alt; use an empty alt only when nearby text already names the person.

Image avatar with initials fallback

Ada LovelaceGH

Avatar groups

<avatar-group>, [data-avatar-group], and .avatar-group overlap direct avatar children while adding a surface-colored separation ring.

Overlapping project members

ALGHKJMH

Give the group a useful accessible label. Each avatar should retain its own name when the individual identities matter.

Stable sizing in flexible layouts

The avatar owns a fixed flex basis, minimum inline size, minimum block size, and square aspect ratio. The adjacent content receives the flexible space.

Avatar beside long content

Narrow the preview: the text wraps while the avatar remains circular.

AG

Avery Gray

A long account description can wrap onto several lines without borrowing width from the identity marker.

Tokens

  • --avatar-size
  • --avatar-radius
  • --avatar-background and --avatar-color
  • --avatar-border-width and --avatar-border-color
  • --avatar-image-fit
  • --avatar-font-weight
  • --avatar-group-overlap
  • --avatar-group-ring-width and --avatar-group-ring-color

Prefer initials or a meaningful image instead of decorative icons. When initials are the only visible content, add aria-label with the complete identity.