An image-like component that has different display options for representing images and icons in different shapes and sizes, depending on the use case.
The shape can be circular or square. There are several predefined sizes, as well as an option to set a custom size.
Keyboard Handling
[SPACE, ENTER, RETURN] - Fires the click event if the interactive property is set to true.
[SHIFT] - If [SPACE] is pressed, pressing [SHIFT] releases the component without triggering the click event.
ES6 Module Import
import "@ui5/webcomponents/dist/Avatar.js";
Properties/Attributes
You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.
Name
Type
Default Value
Description
accessibleName
accessible-name
string
""
Defines the text alternative of the component. If not provided a default text alternative will be set, if present.
since v1.0.0-rc.7
colorScheme
color-scheme
AvatarColorScheme
"Accent6"
Defines the background color of the desired image.
Available options are:
Accent1
Accent2
Accent3
Accent4
Accent5
Accent6
Accent7
Accent8
Accent9
Accent10
Placeholder
icon
string
""
Defines the name of the UI5 Icon, that will be displayed. Note: If image slot is provided, the property will be ignored. Note: You should import the desired icon first, then use its name as "icon".
Defines the displayed initials. Up to three Latin letters can be displayed as initials.
interactive
boolean
false
Defines if the avatar is interactive (focusable and pressable).
shape
AvatarShape
"Circle"
Defines the shape of the component.
Available options are:
Circle
Square
size
AvatarSize
"S"
Defines predefined size of the component.
Available options are:
XS
S
M
L
XL
Slots
This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.
Slot
Type
Description
badge
HTMLElement
Defines the optional badge that will be used for visual affordance. Note: While the slot allows for custom badges, to achieve the Fiori design, please use ui5-badge with ui5-icon in the corresponding icon slot, without text nodes.
Receives the desired <img> tag
Note: If you experience flickering of the provided image, you can hide the component until it is being defined with the following CSS:
ui5-avatar:not(:defined) { visibility: hidden; }
Theme:Morning Horizon (Light)Evening Horizon (Dark)Horizon High Contrast BlackHorizon High Contrast WhiteQuartz LightQuartz DarkQuartz High Contrast BlackQuartz High Contrast White