JGuang

Avatar

Avatar · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Avatar

Used as an avatar, it can be displayed in the form of pictures, icons or characters.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Basic usage. If the avatar content is text, the font size will be automatically adjusted to fit the content in the avatar.
  • Size: Use size to set the size of the avatar, which defaults to 40px. Two shapes are available for the avatar: circle and square.
  • Group: Use Avatar.Group to group a list of avatars. size can be used to specify the size of each avatar.
  • Trigger icon: Customize the interactive button through triggerIcon and triggerType. Two types are available: mask and button. Callbacks can be added through the onClick parameter.
  • Auto fix font Size: If the avatar content is text, the font size will be automatically adjusted to fit the content in the avatar.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Avatar

PropertyDescriptionTypeDefaultValue
autoFixFontSizeWhether to automatically adjust the font size according to the size of the avatar.booleantrue
sizeThe size of the avatar in pxnumber-
shapeThe shape of the avatar. Two shapes are available: circle and square'circle' | 'square'circle
triggerTypeClickable avatar interaction type.'mask' | 'button'button
triggerIconClickable avatar interaction icon.ReactNode-
classNameAdditional css classstring | string[]-
styleAdditional styleCSSProperties-
triggerIconStyleInteractive icon styleCSSProperties-
onClickCallback when avatar is clicked(e) => void-

Avatar.Group

PropertyDescriptionTypeDefaultValueVersion
autoFixFontSizeWhether to automatically adjust the font size according to the size of the avatar (the priority is lower than the Avatar component itself)booleantrue-
zIndexAscendWhether z-index of the avatars in group are in ascending order. The default is in descending order.boolean-2.3.0
maxCountThe maximum number of avatars displayed in the avatar group. The rest of avatars will be displayed as a +x.number-2.4.0
sizeThe size of the avatar in px, (the priority is lower than the Avatar component itself)number--
shapeThe shape of the avatar, (priority is lower than the Avatar component itself)'circle' | 'square'circle-
classNameAdditional css classstring | string[]--
maxPopoverTriggerPropsTriggerProps for popover around +x.TriggerProps-2.4.0
maxStyleStyle for +x.CSSProperties-2.4.0
styleAdditional styleCSSProperties--