Avatar
Puts a face to a name, or initials when there's no photo.
Examples
MLplus 24.00 US dollars
Maya Lens
Dinner on Friday
- MLMaya
- NHNoor
- TRTomas
MLNHTRPN
4 saving togetherSizes
- ML
xs
- NH
sm
- TR
mddefault
- AT
lg
States
- ML
image
- ML
fallback
- ML
image failed
Usage
When to use it
- Use
- Who a payment is with or who owns something: a friend on a split bill, a household member.
- Use
- A stack of people on a shared goal (AvatarGroup).
- Not for
- The image is a receipt or a merchant logo.
- Not for
- The element labels a state. Use Badge.
Rules
7 rules
- Must
- Pass name with the full name. Because it is the image alt and the initials, so an empty name leaves an unnamed image and a blank disc.
- Must
- Pass the display name, not the handle. Because initials come from the first two words, so "@mayaslens" draws an @ in the disc.
- Should
- Show four avatars and a count after them; discs overlap by about an eighth, so every person still widens the row.
- Should
- Keep the name as visible text beside an avatar and hide the avatar from assistive tech.
- Should
- Match size to the line: xs for 14px text, sm for a row, md for a card, lg for a profile.
- Never
- Add an online dot, gradient or extra ring. Because Lime tracks no presence, so a dot or lime ring claims an online status nothing backs.
- Must
- Wrap an avatar that opens a profile in a Button or link. Because the avatar is a span with no focus or role, so an onClick on it is out of keyboard reach.
Accessibility
4 checks
- The image uses name as alt; the fallback is role="img" labelled with the name.
- Not focusable; it takes no keys.
- Beside a visible name the person is read twice; hide the avatar.
- Name an AvatarGroup with aria-label.
Edge cases
6 edge cases
- One-word or emoji name
- Initials are the first grapheme of each of the first two words, so an emoji stays whole.
- Image fails
- The initials show, with no layout shift.
- Right to left
- The overlap is a logical margin, so the first avatar sits at the right edge and the stack runs leftward.
- Empty name
- An empty grey disc with no initials and empty alt text.
- Forced colors
- Every avatar gets a 1px CanvasText border; the group ring is dropped.
- Zoom 200%
- Sizes are pixels; the disc does not grow.
API
4 props
namestringsrcstringsize'xs' | 'sm' | 'md' | 'lg'default'md'AvatarGroupdiv props
Tokens
8 tokens
--surface-2- #efeeea
--fg-2- #4a4943
--radius-control- 999px
--weight-medium- 500
--text-xs- 12px
--text-sm- 14px
--text-lg- 18px
--page- #ffffff