Avatar

Displays a profile avatar with image and fallback support

pnpm
aube
bun
npm
yarn
pnpm add jsx-email

Usage

Use Avatar for profile images. If src is missing, it renders fallback text.

import { Avatar } from 'jsx-email';

const Email = () => {
  return (
    <Avatar
      src="https://assets.example.com/users/bruce.jpg"
      name="Bruce Wayne"
      width={48}
      height={48}
    />
  );
};

Fallback-only example:

import { Avatar } from 'jsx-email';

const Email = () => {
  return <Avatar name="Bruce Wayne" />;
};

Image Fallbacks

Component Props

src?: string;

Path or URL for the avatar image.

alt?: string;

Accessible alt text for image avatars. If omitted, the component derives text from name or fallback.

name?: string;

A readable label used for alt derivation and fallback initials.

fallback?: string;

Fallback text used when src is not provided.

decorative?: boolean;

Marks the avatar as decorative. Decorative avatars use presentational accessibility attributes.

disableDefaultStyle?: boolean;

If true, instructs the component not to add default style properties to the component. This can be useful when attempting to override default styles with Tailwind or class names.

width?: string | number;

Avatar width. Defaults to 40 when no explicit size is provided.

height?: string | number;

Avatar height. Defaults to 40 when no explicit size is provided.

Caveats

Tips

This component also expresses all of the Common Component Props for ComponentProps<'img'>, except children.