Skip to main content

Avatar

Usage

Definition

An avatar is a representation of an individual user. It can be used as a link to an individual’s account content.

Common Characteristics

Avatars are round and contain a scalable graphic or text. The avatar can be 24px (xs), 32px (sm), 40px (md), or 48px (lg).

Content

An avatar should contain a scalable image of the user. If an image is not available, the avatar should display the user’s first and last initials. If neither is available, the avatar should display a generic person icon.

KY
KY
KY
KY

When displayed with text, maintain at least 8px space.

Code

Default Avatar

Live Editor
Result
Loading...

The default avatar size is small

Avatar Sizes

Live Editor
Result
Loading...

The avatar can be 24px (xs), 32px (sm), 40px (md), or 48px (lg).

Avatar Initials

Live Editor
Result
Loading...

The avatar will display initials from a variety of properties. If an image is provided, the name is moved to the alt attribute of the image.

All Name Attributes

Without Image

Live Editor
Result
Loading...

Display of initials are read in the following order: initials, firstName + lastName, followed by name.

With Image

Live Editor
Result
Loading...

If an image is provided, regardless of other props, the image will be displayed. The alt attribute of the image is set to the name property followed by concatenating the firstName and lastName.

Displaying a Message with Avatar

Live Editor
Result
Loading...
Live Editor
Result
Loading...

Props

All props are optional. If all props are omitted a default avatar image will be shown.

NameTypeDefaultDescription
sizestring"sm"Sets the avatar size to xs, sm, md or lg. When omitted, the default avatar size is small (sm).
initialsstringnullDisplays the user's first and/or last name initials on the avatar. This prop takes precedence over the firstName, lastName and name props
firstNamestringnullDisplays the user's first name initial on the avatar when an image prop is not provided. This prop takes precedence over the name prop.
lastNamestringnullDisplays the user's last name initial on the avatar when an image prop is not provided. This prop takes precedence over the name prop.
namestringnullDisplays the user's first and/or last name initials on the avatar when an image, firstName, lastName or initials prop is not provided.
imagestringnullSets the url for the avatar image. This prop takes precedence over the initials, firstName, lastName and name props.
hrefstringnullSets the url a user is linked to when clicking the avatar.
inlineTextstringnullSets the inline text displayed to the right of the avatar.