Skip to main content

Components

Avatar

Avatar displays an image, initials, or icon for a person, entity, or profile.

aria-label
Description

The name of the person the avatar represents.

Type
string
variant
Description

The shape of the avatar.

Type
"circle" | "square"
Default
circle
initials
Description

Initials to display inside the avatar.

Type
string
children
Description

Image, icon or initials to display inside the avatar. Gets `aria-hidden="true"`

Type
any
NameTypeDefaultDescription
aria-labelstring-

The name of the person the avatar represents.

variant"circle" | "square"circle

The shape of the avatar.

initialsstring-

Initials to display inside the avatar.

childrenany-

Image, icon or initials to display inside the avatar. Gets `aria-hidden="true"`

Usage

Examples

Default Icon

If you do not send any children, Avatar will display a default user icon.

This can be overridden in CSS with the --dsc-avatar-icon-url variable. See list of CSS variables at the bottom of the page.

Sizes

The component is controlled by data-size, and will inherit size from the closest parent with data-size set.

In addition to sm, md and lg, Avatar also supports the xs size.

Colors

All colors in your theme are valid, and the component will inherit the closest data-color.

Variants

The variant prop can be set to square or circle. circle is the default.

With image or icon

If you add images or icons as children, they will automatically get aria-hidden="true" to avoid duplicate information.

You must set aria-label on Avatar yourself to explain who or what the avatar represents.

Composition

The component should be able to be composed into other components. Here is an example of using Avatar inside a Dropdown component.

HTML

Avatar uses the class name ds-avatar on a <span> with role="img".

CSS variables and data attributes

Edit this page on github.com (opens in a new tab)