Skip to main content

Avatar and AvatarGroup

import { Avatar, AvatarGroup } from "@study/ui"

Without a picture, the avatar shows the initials in the person's colour – the same everywhere, because it is calculated from the id (colorKey).

Result
Loading...
Live Editor
<div style={{ display: "flex", gap: 16, alignItems: "center" }}>
  <Avatar name="Mira Hansen" size={48} />
  <AvatarGroup label="4 members">
    <Avatar name="Mira Hansen" colorKey="u1" decorative />
    <Avatar name="Jonas Weber" colorKey="u2" decorative />
    <Avatar name="Sina Ok" colorKey="u3" decorative />
    <Avatar name="Tom Berg" colorKey="u4" decorative />
  </AvatarGroup>
</div>

Variants and states​

Light

MHMHJW–+3

Dark

MHMHJW–+3

When to use​

  • Next to a name: decorative, so that the name is not read out twice.
  • In the app, the picture src from /api/avatars/<id>?v=<version> is enough; if it is missing or does not load, the initials appear.
  • Deleted accounts: gone – grey with a line.

Props​

PropTypeDefaultMeaning
name *string–The person's name, for the initials and the picture's description.
classNamestring–
colorKeystring–Decides the colour of the initials; usually the person's id. Default the name.
decorativeboolean–Hides it from screen readers when the name stands next to it.
goneboolean–A deleted account: grey, with a dash.
sizenumber32Width and height in px.
srcstring | null–The picture; without it, or when it fails, the initials.
PropTypeDefaultMeaning
label *string–Who they are together, e.g. "3 members".
maxnumber4How many to show before "+n".

Accessibility​

  • Standing alone, the avatar is an image with the name as its description.
  • A group has a name ("4 members"); "+2" is there as text.