Avatar
A circular image, or initials on a tray fill, that stands for a person or organisation. AvatarGroup stacks several with an overflow count.
<Avatar name="Ada Lovelace" />
<Avatar name="Grace Hopper" />
<Avatar name="Linus" />Import
import { Avatar, AvatarGroup, getInitials } from "@merid/react";Examples
Sizes
xs 24px, sm 32px, md 40px (default), lg 48px, xl 64px.
<Avatar name="Ada Lovelace" size="xs" />
<Avatar name="Ada Lovelace" size="sm" />
<Avatar name="Ada Lovelace" size="md" />
<Avatar name="Ada Lovelace" size="lg" />
<Avatar name="Ada Lovelace" size="xl" />Image and fallback
Pass src for a photo. When it is missing or fails to load, the avatar falls back to initials derived from name — the first letter of the first and last word. initials overrides them (at most two characters are shown).

<Avatar name="Broken Image" src="/does-not-exist.png" />
<Avatar name="Acme Corporation" initials="AC" />Group
max limits the visible avatars; the rest collapse into a “+N” chip. Set the group's size to match its avatars so the chip lines up.
<AvatarGroup label="Project members" max={3} size="sm">
<Avatar name="Ada Lovelace" size="sm" />
<Avatar name="Grace Hopper" size="sm" />
<Avatar name="Alan Turing" size="sm" />
<Avatar name="Katherine Johnson" size="sm" />
<Avatar name="Edsger Dijkstra" size="sm" />
</AvatarGroup>API reference
Avatar
Renders a span; the ref and other span attributes are forwarded.
| Prop | Type | Default | Description |
|---|---|---|---|
nameRequired | string | – | Person or entity name. The accessible name and the source of initials. |
src | string | – | Image URL. Falls back to initials when missing or when loading fails. |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Diameter: 24, 32, 40, 48 or 64px. |
initials | string | – | Overrides the derived initials (max 2 characters shown). |
AvatarGroup
Renders a div with role="group".
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | – | Accessible name of the group, e.g. "Project members". Required unless you pass `aria-label` or `aria-labelledby`; a development warning is logged otherwise. |
max | number | – | Maximum avatars shown; the rest collapse into a +N chip. |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Size of the overflow chip; match the avatars' size. |
children | ReactNode | – | Avatar elements. |
getInitials
getInitials(name: string): string returns up to two upper-case initials — getInitials("Ada Lovelace") is "AL", getInitials("Linus") is "L".
Styling
| Hook | Values |
|---|---|
.mrd-avatar | Root circle |
.mrd-avatar__image | The <img> |
.mrd-avatar__fallback | Initials |
.mrd-avatar-group, .mrd-avatar-group__overflow | Group row and +N chip |
data-size | xs · sm · md · lg · xl |
data-status | image · fallback |
Component variable: --mrd-avatar-size, set per size.
Accessibility
- Each avatar is
role="img"named byname; the inner image hasalt=""and the initials are hidden, so the name is read once. - The overflow chip is announced as “N more”.
- The group has
role="group"; name it withlabel(“Project members”) so the list has context. - When an avatar sits next to the person's visible name, the name is read twice; pass
aria-hiddenon the avatar in that case.
Guidelines
Do
Always pass the real name, even with an image — it is the fallback and the accessible name.
Avoid
Pass a placeholder name like “User” or leave initials to guess from an email address.