Avatar
A user profile image with an automatic text fallback.
Import
import { Avatar } from '@matix/components/avatar';Usage

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

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
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | — | Image source URL |
alt | string | — | Accessible name; omit it to make the avatar decorative |
fallback | ReactNode | — | Content shown when the image fails to load (usually initials) |
size | 'sm' | 'md' | 'lg' | 'md' | Avatar size |
sx | StyleXStyles | — | StyleX style override |
fallbackSx | StyleXStyles | — | 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 examplealt="Mira Patel". - Without
alt, the avatar is decorative and hidden from assistive tech. Omitaltonly 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.
altgives the name instead.
This is an RSC-safe component — it ships no JavaScript to the browser.