Avatar
A person at a glance: a photo or initials, in three sizes, alone, beside a name, or in a group.
Choices
MOMOMO
Initials
Small 32, medium 40, large 56 pixels. Used when there is no photo.
Photo
Cropped to a circle. An illustration here, for the demo.
Photo did not load
Falls back to initials, never a broken image.
Maya Ortiz
With a name
The avatar is hidden from screen readers, so the name is heard once.
- MO
- JB
- AR
- +3
Group
A few faces, then a count of the rest.
Made-up names, for the demo.
Code
Plain HTML for any site, or React. Both use the same styles, so the avatar looks the same wherever it lands.
ReadyAny website, Shopify, WordPress, Square, plain hosting
<link rel="stylesheet" href="tokens.css">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="parts.css">
<!-- Alone: the avatar is the only place the name appears, so it carries the name. -->
<span class="prism-avatar" role="img" aria-label="Maya Ortiz">MO</span>
<span class="prism-avatar prism-avatar--lg" role="img" aria-label="Maya Ortiz"><img src="maya.jpg" alt=""></span>
<!-- Beside the name: hide it, so screen readers do not hear the name twice. -->
<span class="prism-person">
<span class="prism-avatar" aria-hidden="true">MO</span>
<span><span class="prism-person__name">Maya Ortiz</span><span class="prism-person__meta">Designer</span></span>
</span>
<!-- Group: a few faces, then a count. -->
<ul class="prism-avatar-group" aria-label="Project members">
<li><span class="prism-avatar" role="img" aria-label="Maya Ortiz">MO</span></li>
<li><span class="prism-avatar" role="img" aria-label="Jon Bell">JB</span></li>
<li><span class="prism-avatar" role="img" aria-label="Ana Reyes">AR</span></li>
<li><span class="prism-avatar prism-avatar--count" role="img" aria-label="and 3 more">+3</span></li>
</ul>
<!-- Sizes: prism-avatar--sm (32px), default (40px), prism-avatar--lg (56px). -->Accessibility
- Alone, an avatar carries the person's name for screen readers. Next to the visible name, it is hidden so the name is heard once.
- A photo that fails to load falls back to initials instead of a broken image.
- Initials sit on a token background that passes contrast in every theme and brand.
- In a group, the count says how many more, in words for screen readers.
- An avatar is a picture, not a button. If it opens a profile, wrap it in a link that names the person.