Skip to content
EspañolEnglish
All components (283)

Avatar group

Surfaces · AvatarGroup · .amset-avatars

What it is and when to use it

Several stacked avatars, with a "+N" at the end for those that do not fit. It is a real list, and the "+N" says who the hidden ones are: a bare "+3" does not inform.

When to use it

  • Who is in something: a project team, the attendees of an appointment, who has seen a document.
  • people is the list, each person with their name (and src if there is a photo). max decides how many are shown before the "+N" (4 by default). At least one is always shown.
  • size, shape and variant are those of Avatar and apply to all of them.
  • With the mouse, each avatar shows its name (tooltips, on by default), and the "+N" opens the list of the ones not shown with their avatar and name (restPanel, on by default).
  • total when the list brings only a few (the first ones of a query): the "+N" counts up to the total and those not in the list are said as "N more".

When not to

  • A single person: Avatar.
  • When people have to be chosen or distributed (assign, remove): SelectableList or TransferList, with the names written out. The group only shows.

Keyboard: the avatars are not focusable. The "+N" is a button: Enter or Space open the list and Escape closes it and returns focus.

Accessibility: it is a ul with a name (label, required) and one li per avatar, announced with the person's name. The "+N" is read with the missing names: "and 2 more: Jorge Peña, Sara Lima". The name on hover is for whoever is looking: the screen reader already hears it in the avatar's name.

Fine-tuning: the Avatar variables (--amset-avatar-size, --amset-avatar-text, --amset-avatar-ring…) and --amset-avatars-overlap, how much they overlap: 0.5rem (0.375rem in xs; 0.75rem in lg and xl). The ring, in the color of the surface, is what separates them: if the group sits on another background, change --amset-avatar-ring.

What it looks like

<AvatarGroup
  label="Project team"
  people={[
    { key: 'ada', name: 'Ada Lovelace' },
    { key: 'grace', name: 'Grace Hopper' },
  ]}
/>

Props

Import it with import { AvatarGroup } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringWhat is being listed: "Project team", "Attendees". Required.
peoplerequiredreadonly AvatarPerson[]—
classNamestringMerged with the library classes; it does not replace them.
maxnumberHow many are shown before the "+N".
restPanelbooleanThe "+N" opens the list of the ones not shown, with their avatar and name. On by default.
shapeAvatarShape—
size"xs" | "sm" | "md" | "lg" | "xl"—
tooltipsbooleanEach one's name when the mouse passes over it. On by default.
totalnumberHow many there are in total, if the list brings only a few (the first ones of a paged query). The "+N" counts up to here and those not in the list are said as "N more".
variantAvatarVariant—

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-avatars-overlap0.5rem

How to change it

.amset-avatars {
  --amset-avatars-overlap: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: