Back to Element Plus

Avatar

docs/en-US/component/avatar.md

2.13.76.8 KB
Original Source

Avatar

Avatars can be used to represent people or objects. It supports images, Icons, or characters.

Basic Usage

Use shape and size prop to set avatar's shape and size.

:::demo

avatar/basic

:::

Types

It supports images, Icons, or characters.

:::demo

avatar/types

:::

Fallback

fallback when image load error.

:::demo

avatar/fallback

:::

Fit Container

Set how the image fit its container for an image avatar, same as object-fit.

:::demo

avatar/fit

:::

Avatar Group ^(2.13.1)

Displayed as a avatar group.

:::demo Use tag <el-avatar-group> to group your avatars.

avatar/group

:::

Avatar API

Avatar Attributes

NameDescriptionTypeDefault
iconrepresentation type to icon, more info on icon component.^[string] / ^[Component]
sizeavatar size.^[number] / ^[enum]'large' | 'default' | 'small'
shapeavatar shape.^[enum]'circle' | 'square'
srcthe source of the image for an image avatar.string
src-setnative attribute srcset of image avatar.string
altnative attribute alt of image avatar.string
fitset how the image fit its container for an image avatar.^[enum]'fill' | 'contain' | 'cover' | 'none' | 'scale-down'cover

Avatar Events

NameDescriptionType
errortrigger when image load error.^[Function](e: Event) => void

Avatar Slots

NameDescription
defaultcustomize avatar content.

AvatarGroup API ^(2.13.1)

AvatarGroup Attributes

NameDescriptionTypeDefault
sizecontrol the size of avatars in this avatar-group^[number] / ^[enum]'large' | 'default' | 'small'
shapecontrol the shape of avatars in this avatar-group^[enum]'circle' | 'square'
collapse-avatarswhether to collapse avatars^[boolean]false
collapse-avatars-tooltipwhether show all collapsed avatars when mouse hover text of the collapse-avatar. To use this, collapse-avatars must be true^[boolean]false
max-collapse-avatarsthe max avatars number to be shown. To use this, collapse-avatars must be true^[number]1
effecttooltip theme, built-in theme: dark / light^[enum]'dark' | 'light' / ^[string]light
placementplacement of tooltip^[enum]'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'top
popper-classcustom class name for tooltip^[string]''
popper-stylecustom style for tooltip^[string] / ^[object]
collapse-classcustom class name for the collapse-avatar^[string]''
collapse-stylecustom style for the collapse-avatar^[string] / ^[object]