Back to Ant Design

Avatar

components/avatar/index.en-US.md

6.3.72.7 KB
Original Source

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/type.tsx">Type</code> <code src="./demo/dynamic.tsx">Autoset Font Size</code> <code src="./demo/badge.tsx">With Badge</code> <code src="./demo/group.tsx">Avatar.Group</code> <code src="./demo/toggle-debug.tsx" debug>Calculate text style when hiding</code> <code src="./demo/responsive.tsx">Responsive Size</code> <code src="./demo/fallback.tsx" debug>Fallback</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

Avatar

PropertyDescriptionTypeDefaultVersion
altThis attribute defines the alternative text describing the imagestring-
gapLetter type unit distance between left and right sidesnumber44.3.0
iconCustom icon type for an icon avatarReactNode-
shapeThe shape of avatarcircle | squarecircle
sizeThe size of the avatarnumber | large | medium | small | { xs: number, sm: number, ...}medium4.7.0
srcThe address of the image for an image avatar or image elementstring | ReactNode-ReactNode: 4.8.0
srcSetA list of sources to use for different screen resolutionsstring-
draggableWhether the picture is allowed to be draggedboolean | 'true' | 'false'true
crossOriginCORS settings attributes'anonymous' | 'use-credentials' | ''-4.17.0
onErrorHandler when img load error, return false to prevent default fallback behavior() => boolean-

Tip: You can set icon or children as the fallback for image load error, with the priority of icon > children

Avatar.Group <Badge>4.5.0+</Badge>

PropertyDescriptionTypeDefaultVersion
maxSet maximum display related configurations{ count?: number; style?: CSSProperties; popover?: PopoverProps }-5.18.0
maxCountDeprecated, please use max={{ count: number }}number-
maxPopoverPlacementDeprecated, please use max={{ popover: PopoverProps }}top | bottomtop
maxPopoverTriggerDeprecated, please use max={{ popover: PopoverProps }}hover | focus | clickhover
maxStyleDeprecated, please use max={{ style: CSSProperties }}CSSProperties-
sizeThe size of the avatarnumber | large | medium | small | { xs: number, sm: number, ...}medium4.8.0
shapeThe shape of the avatarcircle | squarecircle5.8.0

Design Token

<ComponentTokenTable component="Avatar"></ComponentTokenTable>