Skip to main content

Avatar

Use cases:

  • Display an image or text (usually initials) to represent a user.
  • Personalise the experience for a user

Example

JD

Declaration

<rapid-avatar shape="circle"></rapid-avatar>

Usage

@customElement({
name: 'my-element',
template: html`
<rapid-avatar shape="circle"></rapid-avatar>
`,
})
export class MyElement extends GenesisElement {
}

API

Property and attribute binding examples for Genesis Component syntax. Closing tag omitted.

NameTypeDescriptionExample
altstringAlternate text to display.
<rapid-avatar alt="User Profile Image">
linkstringURL link assigned to the avatar.
<rapid-avatar link="https://someLink">
namestringThe name associated to the avatar
<rapid-avatar name="JohnDoe">
shape"circle" | "square"The shape of the avatar. Defaults to circle
<rapid-avatar shape="circle">
fillstringBackground fill colour of the avatar
<rapid-avatar fill="primary">
colorstringThe text color of the avatar.
<rapid-avatar color="dark">
note

The fill and color attributes of the avatar create CSS custom properties, which can be used to style the control. Pass in the css name minus the "avatar-fill-" string for fill. Pass in the css name minus the "avatar-color-" string for color.

alpha-avatar {
--avatar-fill-primary: #0EAFE2;
--avatar-fill-danger: #ff0000;
--avatar-color-light: #ffffff;
--avatar-color-dark: #000000;
}

Properties

This component doesn't have any properties which are not also controlled via attributes.

Slots

NameDescription
mediaUsed for media such as an image.
DefaultThe default slot for avatar text, commonly a name or initials.
badgeUsed to provide a badge, such as a status badge.

Parts

NameDescription
backplateThe wrapping container for the avatar.
linkThe avatar link.
mediaThe media slot.
contentThe default slot.

Events fired

This component doesn't fire any events.

Events listened to

This component doesn't listen to any events.