MiHCM
data/@mihcm/ui·v0.21.0·stable

Avatar

User portrait. Compose Avatar + AvatarImage + AvatarFallback — fallback shows on image error and during load.

Avatar

A composable user or entity portrait with automatic image-to-fallback handling.

When to use

  • User profiles — navigation bars, comment threads, team lists.
  • Entity representation — company logos, workspace icons.
  • Grouped lists — participant avatars in a meeting or channel.

When NOT to use

  • For decorative illustrations unrelated to an entity — use a plain <img>.
  • For icons or badges — use Badge or an icon component.

Import

import { Avatar, AvatarImage, AvatarFallback } from '@mihcm/ui/Avatar';

Basic usage

<Avatar>
  <AvatarImage src="/people/photos/jane-doe.jpg" alt="Jane Doe" />
  <AvatarFallback>JD</AvatarFallback>
</Avatar>

The image renders first. If it fails to load, the fallback shows automatically.

Sizes

SizeDimensionsUse when
sm32 x 32Dense lists, inline mentions.
md40 x 40Default for most UIs.
lg48 x 48Profile headers, cards.
xl64 x 64Profile pages, hero sections.

Composition

  • AvatarFallback is always in the DOM behind the image so layout never shifts on load failure.
  • Use initials (1-2 characters) or an icon as fallback content.
  • Badge — status indicator that can overlay an avatar.