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–+3Dark
MHMHJW–+3When to use
- Next to a name:
decorative, so that the name is not read out twice. - In the app, the picture
srcfrom/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
| Prop | Type | Default | Meaning |
|---|---|---|---|
name * | string | – | The person's name, for the initials and the picture's description. |
className | string | – | |
colorKey | string | – | Decides the colour of the initials; usually the person's id. Default the name. |
decorative | boolean | – | Hides it from screen readers when the name stands next to it. |
gone | boolean | – | A deleted account: grey, with a dash. |
size | number | 32 | Width and height in px. |
src | string | null | – | The picture; without it, or when it fails, the initials. |
| Prop | Type | Default | Meaning |
|---|---|---|---|
label * | string | – | Who they are together, e.g. "3 members". |
max | number | 4 | How 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.