Mosmox UI
Current version
GitHubnpmjs.com
Content & Media

Avatar

Flexible user and entity avatars with fallbacks, status indicators, shapes and interaction.

Avatar represents a person, team or entity using an image, initials, an icon or custom content.

Open the interactive Avatar examples on the component showcase →

Content and fallback

Use image with an accessible alt or name. If the image fails, Avatar falls back to initials, initials derived from name, children, or icon.

<Avatar image="/avatar.jpg" name="Alex Johnson" alt="Alex Johnson" />
<Avatar name="Alex Johnson" />
<Avatar initials="MK" />
<Avatar icon={<UserIcon />} />

Size, shape and appearance

size is xs, sm, default, lg, xl or xxl. The showcase includes ten content and state examples for each of the four common sizes: xs, sm, default and lg. shape is circle, rounded or square. variant is soft (default), solid or outline.

<Avatar name="Small" size="sm" />
<Avatar name="Large" size="lg" shape="rounded" variant="solid" />
<Avatar name="Team" size="xl" shape="square" variant="outline" />

The default dimensions are:

SizeDimensionsTypical use
xs24 × 24pxDense tables, compact metadata and inline mentions.
sm32 × 32pxLists, comments and compact navigation.
default40 × 40pxStandard profile and team references.
lg48 × 48pxCards, headers and prominent identity blocks.
xl64 × 64pxProfile headers and large identity displays.
xxl96 × 96pxExtra-large profile photos and prominent identity displays.

Each size supports the same content sources and states: an image, initials derived from name, explicit initials, an icon or custom children, status indicators, loading and disabled states, as well as all three shapes and visual variants.

<Avatar size="xs" image="/avatar.jpg" alt="Small profile photo" />
<Avatar size="sm" initials="MK" variant="solid" />
<Avatar size="default" name="Alex Johnson" status="online" />
<Avatar size="lg" icon={<UserIcon />} shape="rounded" variant="outline" />
<Avatar size="xxl" image="/profile-photo.jpg" alt="Large profile photo" />

Extra extra large examples

The xxl size is 96 × 96px and supports the same content and state combinations as every other size:

<Avatar size="xxl" image="/profile-photo.jpg" alt="Large profile photo" />
<Avatar size="xxl" name="Alex Johnson" />
<Avatar size="xxl" initials="MK" variant="solid" />
<Avatar size="xxl" icon={<UserIcon />} variant="outline" />
<Avatar size="xxl" name="Online" status="online" />
<Avatar size="xxl" name="Rounded" shape="rounded" />
<Avatar size="xxl" name="Loading" loading />

Use xxl for prominent profile headers, account pages, team identity blocks or other places where the avatar is the primary visual focus. It is approximately 1.5 times larger than xl.

Status and states

status accepts online, offline, busy or away. Override its accessible announcement with statusLabel. loading displays a loading state; disabled reduces emphasis and disables interaction.

Interaction

Providing onClick makes Avatar keyboard accessible with button semantics. Enter and Space activate it. Use aria-label when the name is not visible.

Interactive avatars use the same motion language as Button: they lift by 2px on hover and return to their original position when pressed. Set hoverScale to scale the whole avatar by 1.06 instead of lifting it. Set disableHover to disable both hover motion and the hover shadow. These effects are only applied when onClick makes the avatar interactive.

<Avatar name="Lift on hover" onClick={openProfile} />
<Avatar name="Scale on hover" hoverScale onClick={openProfile} />
<Avatar name="No hover effect" disableHover onClick={openProfile} />

API Reference

PropValuesDefaultDescription
imagestring—Image URL.
altstringnameImage alternative text.
namestring—Accessible name and automatic initials source.
initialsstringderivedExplicit fallback content.
children / iconReactNode—Custom fallback content.
sizexs | sm | default | lg | xl | xxldefaultAvatar dimensions. xxl is 96×96px, approximately 1.5 times the xl size.
shapecircle | rounded | squarecircleCorner treatment.
variantsoft | solid | outlinesoftFallback appearance.
statusonline | offline | busy | away—Status indicator.
statusLabelstringstatusAccessible status text.
loading, disabledbooleanfalseState flags.
hoverScalebooleanfalseScales an interactive avatar to 1.06 on hover instead of lifting it.
disableHoverbooleanfalseDisables hover motion and shadow for an interactive avatar.
onClickfunction—Makes the avatar interactive.
aria-labelstringname or altAccessible name for the avatar.
classNamestring—Additional class name applied to the root element.

When image is present, it takes precedence over fallback content. If the image fails to load, the fallback order is initials, initials derived from name, children, then icon. An interactive avatar supports Enter and Space keyboard activation and exposes button semantics.