Avatar
A small image or initials that stand for a person or account.
In Content first
See it live
npm run storybookWhen to use it
In Content first: The author of an article.
- Use it when: Showing who wrote, owns or is signed in, next to their name.
- Not when: The only way to tell people apart, or decoration with no person behind it.
Instead:
- Badge: A status or count, not a person.
Words
- Write to one person: "you", not "users".
- Short sentences with room to breathe.
- Explain why before asking for anything.
- Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Browse guides
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- The person's name is in text nearby or in the image's alternative text; initials alone are not a name. undefined
Use it in code
npx open-ds add avatar
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Avatar reads 19 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Avatar's tokens to change Avatar alone.
Content first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Avatar | ||
| Size | component.avatar.sizesize.control.defaultvar(--avatar-size) | size.48:3rem |
| Corner | component.avatar.radiusradius.roundvar(--avatar-radius) | radius.full:9999px |
| Fallback | ||
| Corner | component.avatar.fallback.radiusradius.roundvar(--avatar-fallback-radius) | radius.full:9999px |
| Fill Changes with theme | component.avatar.fallback.backgroundcolor.surface.sunkenvar(--avatar-fallback-background) | Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24 |
| Text size | component.avatar.fallback.font-sizetype.body.font-sizevar(--avatar-fallback-font-size) | font.size.18:1.125rem |
| Text Changes with theme | component.avatar.fallback.labelcolor.text.mutedvar(--avatar-fallback-label) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| Font size 2 | component.avatar.fallback.font-size-2type.caption.font-sizevar(--avatar-fallback-font-size-2) | font.size.14:0.875rem |
| Badge | ||
| Corner | component.avatar.badge.radiusradius.roundvar(--avatar-badge-radius) | radius.full:9999px |
| Fill Changes with theme | component.avatar.badge.backgroundcolor.action.primaryvar(--avatar-badge-background) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Text Changes with theme | component.avatar.badge.labelcolor.text.on-actionvar(--avatar-badge-label) | Lightstone.light.0:#FFFFFFDarkstone.light.900:#1F1B16 |
| Focus ring Changes with theme | component.avatar.badge.focus-ringcolor.surface.canvasvar(--avatar-badge-focus-ring) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Group | ||
| Focus ring Changes with theme | component.avatar.group.focus-ringcolor.surface.canvasvar(--avatar-group-focus-ring) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Count size | component.avatar.group.count.sizesize.control.defaultvar(--avatar-group-count-size) | size.48:3rem |
| Count radius | component.avatar.group.count.radiusradius.roundvar(--avatar-group-count-radius) | radius.full:9999px |
| Count background Changes with theme | component.avatar.group.count.backgroundcolor.surface.sunkenvar(--avatar-group-count-background) | Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24 |
| Count font size | component.avatar.group.count.font-sizetype.body.font-sizevar(--avatar-group-count-font-size) | font.size.18:1.125rem |
| Count label Changes with theme | component.avatar.group.count.labelcolor.text.mutedvar(--avatar-group-count-label) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| Count focus ring Changes with theme | component.avatar.group.count.focus-ringcolor.surface.canvasvar(--avatar-group-count-focus-ring) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Count icon size | component.avatar.group.count.icon-sizesize.iconvar(--avatar-group-count-icon-size) | size.16:1rem |