Skip to main content

What are you looking for?

Try searching for…

Components

Avatar

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

aria-label
Type
string
data-tooltip
Type
string
aria-hidden
Type
Booleanish
variant
Description

The shape of the avatar.

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

Initials to display inside the avatar.

Type
string
asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
children
Description

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

Type
ReactNode
NameTypeDefaultDescription
aria-labelstring-

-

data-tooltipstring-

-

aria-hiddenBooleanish-

-

variant"circle" | "square"circle

The shape of the avatar.

initialsstring-

Initials to display inside the avatar.

asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

childrenReactNode-

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)