Avatar

A user profile image with an automatic text fallback.

Import

import { Avatar } from '@matix/components/avatar';

Usage

Mate Rauscher

Fallback

When the image fails to load or no src is provided, Avatar displays the fallback text (typically initials).

<Avatar
  src="https://pbs.twimg.com/profile_images/1694183046755573760/UuZAiZXE_400x400.jpg"
  alt="Mate Rauscher"
  fallback="MR"
/>
<Avatar fallback="JD" />
<Avatar src="/broken-url.png" alt="Broken" fallback="BR" />

Sizes

Mate RauscherAlex KimMaya Patel

Custom Styles

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  square: { borderRadius: '4px' },
});

<Avatar fallback="SQ" sx={custom.square} />;

Custom Fallback

The fallback inherits the shape of the root, so sx with a borderRadius changes both. Use fallbackSx to change the fallback colors.

API Reference

PropTypeDefaultDescription
srcstring—Image source URL
altstring—Accessible name; omit it to make the avatar decorative
fallbackReactNode—Content shown when the image fails to load (usually initials)
size'sm' | 'md' | 'lg''md'Avatar size
sxStyleXStyles—StyleX style override
fallbackSxStyleXStyles—StyleX style override for the fallback layer (colors, font)

All other HTML attributes, such as id and aria-*, go to the root element.

Accessibility

  • With alt, the avatar is an image with that name, for example alt="Mira Patel".
  • Without alt, the avatar is decorative and hidden from assistive tech. Omit alt only when the name is visible next to the avatar, as in a user menu, so screen readers do not read the name twice.
  • The fallback initials are always hidden from assistive tech. alt gives the name instead.

This is an RSC-safe component — it ships no JavaScript to the browser.