# Avatar

- Page: https://jiguang132.com/resources/material-ui/docs/avatars
- Resource: Material UI (https://jiguang132.com/resources/material-ui.md)
- All guides: https://jiguang132.com/resources/material-ui/docs.md

Identify people or entities with images, initials or icons, individually or in groups.

This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.

## Use case and business boundary

Images require meaningful alt text and network fallback; a group total is supplied data, not a fetched user count.

## Native composition and scope

`Avatar`, `AvatarGroup`, `Badge`

Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.

## Native installation and initialization

```bash
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
```

Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.

## Practical native parameters

These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.

| Owner.prop | Practical role | Declaration source |
| --- | --- | --- |
| `Avatar.src` | Host-supplied image URL, requiring media failure handling. | `Avatar` |
| `Avatar.alt` | Meaningful alternative text for a supplied image. | `Avatar` |
| `Avatar.variant` | Owning native presentation enum; never substitute a universal variant prop. | `Avatar` |
| `AvatarGroup.max` | Badge visible-count limit or Slider maximum; preserve the owner and units. | `AvatarGroup` |
| `AvatarGroup.total` | Host-supplied total avatars, independent of rendered child count. | `AvatarGroup` |

## Runnable native examples

Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.

- Image avatars · `ImageAvatars` · upstream native demo
- Letter avatars · `LetterAvatars` · upstream native demo
- Letter avatars · `BackgroundLetterAvatars` · upstream native demo
- Sizes · `SizeAvatars` · upstream native demo
- Icon avatars · `IconAvatars` · upstream native demo
- Variants · `VariantAvatars` · upstream native demo
- Fallbacks · `FallbackAvatars` · upstream native demo
- Grouped · `GroupAvatars` · upstream native demo
- Total avatars · `TotalAvatars` · upstream native demo
- Custom surplus · `CustomSurplusAvatars` · upstream native demo
- Spacing · `Spacing` · upstream native demo
- With badge · `BadgeAvatars` · upstream native demo
- Avatar upload · `UploadAvatars` · upstream native demo

## Actual usage example

Unmodified pinned native demo; copy its required local helper files together.

```tsx
import Avatar from '@mui/material/Avatar';
import Stack from '@mui/material/Stack';

export default function ImageAvatars() {
  return (
    <Stack direction="row" spacing={2}>
      <Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
      <Avatar alt="Travis Howard" src="/static/images/avatar/2.jpg" />
      <Avatar alt="Cindy Baker" src="/static/images/avatar/3.jpg" />
    </Stack>
  );
}

```

## Example dependency boundaries

`@mui/material/Avatar`, `@mui/material/Stack`, `@mui/material/colors`, `@mui/icons-material/Folder`, `@mui/icons-material/Pageview`, `@mui/icons-material/Assignment`, `@mui/material/AvatarGroup`, `@mui/material/styles`, `@mui/material/Badge`, `@mui/icons-material/InsertDriveFile`, `react`, `@mui/material/ButtonBase`

Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.

## Pinned upstream API metadata reference

These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.

### Avatar

```tsx
import Avatar from '@mui/material/Avatar';
import { Avatar } from '@mui/material';
```

| Prop | Required | Upstream metadata type / constraint | Metadata default |
| --- | --- | --- | --- |
| `alt` | no | `string` | — |
| `children` | no | `node` | — |
| `classes` | no | `object` | — |
| `component` | no | `elementType` | — |
| `sizes` | no | `string` | — |
| `slotProps` | no | `{ fallback?: func \| object, img?: func \| object, root?: func \| object }` | `{}` |
| `slots` | no | `{ fallback?: elementType, img?: elementType, root?: elementType }` | `{}` |
| `src` | no | `string` | — |
| `srcSet` | no | `string` | — |
| `sx` | no | `Array<func \| object \| bool> \| func \| object` | — |
| `variant` | no | `'circular' \| 'rounded' \| 'square' \| string` | `'circular'` |



### AvatarGroup

```tsx
import AvatarGroup from '@mui/material/AvatarGroup';
import { AvatarGroup } from '@mui/material';
```

| Prop | Required | Upstream metadata type / constraint | Metadata default |
| --- | --- | --- | --- |
| `children` | no | `node` | — |
| `classes` | no | `object` | — |
| `component` | no | `elementType` | — |
| `max` | no | `number` | `5` |
| `renderSurplus` | no | `func` | — |
| `slotProps` | no | `{ surplus?: func \| object }` | `{}` |
| `slots` | no | `{ surplus?: elementType }` | `{}` |
| `spacing` | no | `'medium' \| 'small' \| number` | `'medium'` |
| `sx` | no | `Array<func \| object \| bool> \| func \| object` | — |
| `total` | no | `number` | `children.length` |
| `variant` | no | `'circular' \| 'rounded' \| 'square' \| string` | `'circular'` |



### Badge

```tsx
import Badge from '@mui/material/Badge';
import { Badge } from '@mui/material';
```

| Prop | Required | Upstream metadata type / constraint | Metadata default |
| --- | --- | --- | --- |
| `anchorOrigin` | no | `{ horizontal?: 'left' \| 'right', vertical?: 'bottom' \| 'top' }` | `{ vertical: 'top', horizontal: 'right', }` |
| `badgeContent` | no | `node` | — |
| `children` | no | `node` | — |
| `classes` | no | `object` | — |
| `color` | no | `'default' \| 'primary' \| 'secondary' \| 'error' \| 'info' \| 'success' \| 'warning' \| string` | `'default'` |
| `component` | no | `elementType` | — |
| `invisible` | no | `bool` | `false` |
| `max` | no | `number` | `99` |
| `overlap` | no | `'circular' \| 'rectangular'` | `'rectangular'` |
| `showZero` | no | `bool` | `false` |
| `slotProps` | no | `{ badge?: func \| object, root?: func \| object }` | `{}` |
| `slots` | no | `{ badge?: elementType, root?: elementType }` | `{}` |
| `sx` | no | `Array<func \| object \| bool> \| func \| object` | — |
| `variant` | no | `'dot' \| 'standard' \| string` | `'standard'` |


## Native source declarations

Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.

### vendor/src/Avatar/Avatar.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { OverridableStringUnion } from '@mui/types';

import { Theme } from '../styles';

import { OverridableComponent, OverrideProps } from '../OverridableComponent';

import { AvatarClasses } from './avatarClasses';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

import { SvgIconProps } from '../SvgIcon';

export interface AvatarSlots {
  /**
   * The component that renders the root slot.
   * @default 'div'
   */
  root: React.ElementType;
  /**
   * The component that renders the img slot.
   * @default 'img'
   */
  img: React.ElementType;
  /**
   * The component that renders the fallback slot.
   * @default Person icon
   */
  fallback: React.ElementType;
}

export interface AvatarPropsVariantOverrides {}

export interface AvatarRootSlotPropsOverrides {}

export interface AvatarImgSlotPropsOverrides {}

export interface AvatarFallbackSlotPropsOverrides {}

export type AvatarSlotsAndSlotProps = CreateSlotsAndSlotProps<
  AvatarSlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the div element.
     */
    root: SlotProps<'div', AvatarRootSlotPropsOverrides, AvatarOwnProps>;
    /**
     * Props forwarded to the img slot.
     * By default, the available props are based on the img element.
     */
    img: SlotProps<'img', AvatarImgSlotPropsOverrides, AvatarOwnProps>;
    /**
     * Props forwarded to the fallback slot.
     * By default, the available props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
     */
    fallback: SlotProps<
      React.ElementType<SvgIconProps>,
      AvatarFallbackSlotPropsOverrides,
      AvatarOwnProps
    >;
  }
>;

export interface AvatarOwnProps {
  /**
   * Used in combination with `src` or `srcSet` to
   * provide an alt attribute for the rendered `img` element.
   */
  alt?: string | undefined;
  /**
   * Used to render icon or text elements inside the Avatar if `src` is not set.
   * This can be an element, or just a string.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AvatarClasses> | undefined;
  /**
   * The `sizes` attribute for the `img` element.
   */
  sizes?: string | undefined;
  /**
   * The `src` attribute for the `img` element.
   */
  src?: string | undefined;
  /**
   * The `srcSet` attribute for the `img` element.
   * Use this attribute for responsive image display.
   */
  srcSet?: string | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The shape of the avatar.
   * @default 'circular'
   */
  variant?:
    | OverridableStringUnion<'circular' | 'rounded' | 'square', AvatarPropsVariantOverrides>
    | undefined;
}

export interface AvatarTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'div',
> {
  props: AdditionalProps & AvatarOwnProps & AvatarSlotsAndSlotProps;
  defaultComponent: RootComponent;
}

declare const Avatar: OverridableComponent<AvatarTypeMap>;

export type AvatarProps<
  RootComponent extends React.ElementType = AvatarTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<AvatarTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};
```

### vendor/src/AvatarGroup/AvatarGroup.d.ts

```ts
import * as React from 'react';

import {
  OverridableComponent,
  OverridableStringUnion,
  OverrideProps,
  PartiallyRequired,
} from '@mui/types';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { AvatarGroupClasses } from './avatarGroupClasses';

import Avatar from '../Avatar';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

export interface AvatarGroupPropsVariantOverrides {}

export interface AvatarGroupComponentsPropsOverrides {}

export interface AvatarGroupSlots {
  surplus: React.ElementType;
}

export type AvatarGroupSlotsAndSlotProps = CreateSlotsAndSlotProps<
  AvatarGroupSlots,
  {
    surplus: SlotProps<
      React.ElementType<React.ComponentPropsWithRef<typeof Avatar>>,
      AvatarGroupComponentsPropsOverrides,
      AvatarGroupOwnerState
    >;
  }
>;

export interface AvatarGroupOwnProps extends AvatarGroupSlotsAndSlotProps {
  /**
   * The avatars to stack.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AvatarGroupClasses> | undefined;
  /**
   * The component used for the root node.
   * Either a string to use a HTML element or a component.
   */
  component?: React.ElementType | undefined;
  /**
   * Max avatars to show before +x.
   * @default 5
   */
  max?: number | undefined;
  /**
   * custom renderer of extraAvatars
   * @param {number} surplus number of extra avatars
   * @returns {React.ReactNode} custom element to display
   */
  renderSurplus?: ((surplus: number) => React.ReactNode) | undefined;
  /**
   * Spacing between avatars.
   * @default 'medium'
   */
  spacing?: 'small' | 'medium' | number | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The total number of avatars. Used for calculating the number of extra avatars.
   * @default children.length
   */
  total?: number | undefined;
  /**
   * The variant to use.
   * @default 'circular'
   */
  variant?:
    | OverridableStringUnion<'circular' | 'rounded' | 'square', AvatarGroupPropsVariantOverrides>
    | undefined;
}

export interface AvatarGroupTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'div',
> {
  props: AdditionalProps & AvatarGroupOwnProps;
  defaultComponent: RootComponent;
}

declare const AvatarGroup: OverridableComponent<AvatarGroupTypeMap>;

export type AvatarGroupProps<
  RootComponent extends React.ElementType = AvatarGroupTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<AvatarGroupTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};

export interface AvatarGroupOwnerState extends PartiallyRequired<
  AvatarGroupProps,
  'max' | 'spacing' | 'component' | 'variant'
> {}
```

### vendor/src/Badge/Badge.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { OverridableStringUnion, Simplify } from '@mui/types';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

import { Theme } from '../styles';

import { OverridableComponent, OverrideProps } from '../OverridableComponent';

import { BadgeClasses } from './badgeClasses';

export interface BadgePropsVariantOverrides {}

export interface BadgePropsColorOverrides {}

export interface BadgeRootSlotPropsOverrides {}

export interface BadgeBadgeSlotPropsOverrides {}

export interface BadgeSlots {
  /**
   * The component that renders the root.
   * @default span
   */
  root: React.ElementType;
  /**
   * The component that renders the badge.
   * @default span
   */
  badge: React.ElementType;
}

export type BadgeSlotsAndSlotProps = CreateSlotsAndSlotProps<
  BadgeSlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the span element.
     */
    root: SlotProps<'span', BadgeRootSlotPropsOverrides, BadgeOwnerState>;
    /**
     * Props forwarded to the label slot.
     * By default, the available props are based on the span element.
     */
    badge: SlotProps<'span', BadgeBadgeSlotPropsOverrides, BadgeOwnerState>;
  }
>;

export type BadgeOwnerState = Simplify<
  Omit<BadgeOwnProps, 'slotProps' | 'slots'> & {
    badgeContent: React.ReactNode;
    invisible: boolean;
    max: number;
    displayValue: React.ReactNode;
    showZero: boolean;
    anchorOrigin: BadgeOrigin;
    color: OverridableStringUnion<
      'primary' | 'secondary' | 'default' | 'error' | 'info' | 'success' | 'warning',
      BadgePropsColorOverrides
    >;
    overlap: 'rectangular' | 'circular';
    variant: OverridableStringUnion<'standard' | 'dot', BadgePropsVariantOverrides>;
  }
>;

export interface BadgeOrigin {
  vertical?: 'top' | 'bottom' | undefined;
  horizontal?: 'left' | 'right' | undefined;
}

export interface BadgeOwnProps extends BadgeSlotsAndSlotProps {
  /**
   * The anchor of the badge.
   * @default {
   *   vertical: 'top',
   *   horizontal: 'right',
   * }
   */
  anchorOrigin?: BadgeOrigin | undefined;
  /**
   * The content rendered within the badge.
   */
  badgeContent?: React.ReactNode;
  /**
   * The badge will be added relative to this node.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<BadgeClasses> | undefined;
  /**
   * @ignore
   */
  className?: string | undefined;
  /**
   * The color of the component.
   * It supports both default and custom theme colors, which can be added as shown in the
   * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
   * @default 'default'
   */
  color?:
    | OverridableStringUnion<
        'primary' | 'secondary' | 'default' | 'error' | 'info' | 'success' | 'warning',
        BadgePropsColorOverrides
      >
    | undefined;
  /**
   * If `true`, the badge is invisible.
   * @default false
   */
  invisible?: boolean | undefined;
  /**
   * Max count to show.
   * @default 99
   */
  max?: number | undefined;
  /**
   * Wrapped shape the badge should overlap.
   * @default 'rectangular'
   */
  overlap?: 'rectangular' | 'circular' | undefined;
  /**
   * Controls whether the badge is hidden when `badgeContent` is zero.
   * @default false
   */
  showZero?: boolean | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The variant to use.
   * @default 'standard'
   */
  variant?: OverridableStringUnion<'standard' | 'dot', BadgePropsVariantOverrides> | undefined;
}

export interface BadgeTypeMap<
  RootComponent extends React.ElementType = 'span',
  AdditionalProps = {},
> {
  props: AdditionalProps & BadgeOwnProps;
  defaultComponent: RootComponent;
}

type BadgeRootProps = NonNullable<BadgeTypeMap['props']['slotProps']>['root'];

type BadgeBadgeProps = NonNullable<BadgeTypeMap['props']['slotProps']>['badge'];

export declare const BadgeRoot: React.FC<BadgeRootProps>;

export declare const BadgeMark: React.FC<BadgeBadgeProps>;

declare const Badge: OverridableComponent<BadgeTypeMap>;

export type BadgeProps<
  RootComponent extends React.ElementType = BadgeTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<BadgeTypeMap<RootComponent, AdditionalProps>, RootComponent> & {
  component?: React.ElementType | undefined;
};
```

## Post-install acceptance

Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.

## Source and license

https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e

MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
