Skip to main content

Components

AvatarStack

AvatarStack stacks a collection of Avatar elements

AvatarStack is under development. If you have feedback or suggestions, please report them on Github or in Slack.

gap
Description

Adjusts gap-mask between avatars in the stack. Must be a valid css length value (px, em, rem, var(--ds-size-1) etc.)

Type
string
Default
2px
avatarSize
Description

Control the size of the avatars. Must be a valid css length value (px, em, rem, var(--ds-size-12) etc.)

Type
string
Default
'var(--ds-size-12)'
overlap
Description

A number which represents the percentage value of how much avatars should overlap.

Type
number
Default
50
suffix
Description

Text to the right of the avatars to show a number representing additional avatars not shown such as '+5'".

Type
string
expandable
Description

Expand on hover to show full avatars. 'fixed': AvatarStack physical width does not change when avatars are expanded.

Type
true | "fixed"
Default
undefined
NameTypeDefaultDescription
gapstring2px

Adjusts gap-mask between avatars in the stack. Must be a valid css length value (px, em, rem, var(--ds-size-1) etc.)

avatarSizestring'var(--ds-size-12)'

Control the size of the avatars. Must be a valid css length value (px, em, rem, var(--ds-size-12) etc.)

overlapnumber50

A number which represents the percentage value of how much avatars should overlap.

suffixstring-

Text to the right of the avatars to show a number representing additional avatars not shown such as '+5'".

expandabletrue | "fixed"undefined

Expand on hover to show full avatars. 'fixed': AvatarStack physical width does not change when avatars are expanded.

Usage

Examples

Customization

AvatarStack is designed to be flexible enough to cover many different needs and use cases.

Expandable

expandable animates overlap to 0 on hover or focus. Use expandable="fixed" to expand with overflow without changing the physical width.

Indicating avatars not shown

AvatarStack does not support wrapping across multiple lines. If there are more avatars than can fit in the stack, you can use suffix to indicate this as text to the right of the stack. This automatically scales with the avatar size. You can also use an Avatar with +xx as initials or child, but you should override the font size on this avatar with --dsc-avatar-font-size if there is to be room for two-digit or higher numbers.

Sizes

You cannot use data-size to change the size of avatars in an AvatarStack. Instead, the size is controlled via the avatarSize prop on AvatarStack. This must be specified in a valid CSS length unit (px, em, rem, var(--ds-size-6), etc.).

Gap

AvatarStack uses CSS mask to create the visible space between avatars. The default is 2px but can be customized with gap

Avatars in AvatarStack can have tooltips and be links, but be aware of accessibility considerations. Use asChild to make an Avatar a link.

HTML

To create an AvatarStack in plain HTML, use the ds-avatar-stack class on a <figure>. Inside this, place elements with the ds-avatar class. Note that if you want to use data-expandable="fixed", the number of avatars must be specified via --dsc-avatar-count: <number> to correctly calculate the fixed width. Use data-suffix to add a text indicator for hidden avatars.

To override the default gap/size/overlap, use these CSS variables:

CSS variables and data attributes

CSS Variables
NameValue
--dsc-avatar-stack-sizevar(--ds-size-12)
--dsc-avatar-stack-gap2px
--dsc-avatar-stack-overlap50
--dsc-avatar-countinitial
--dsc-avatar-sizevar(--dsc-avatar-stack-size)
--dsc-avatar-font-sizevar(--_font-size)
Data Attributes
NameValue
data-expandablefixed
data-suffix
data-variantsquare
Edit this page on github.com (opens in a new tab)