Avatar
A small image or initials that stand for a person or account.
In Multi-brand
See it live
npm run storybookWhen to use it
In Multi-brand: The customer in the account menu.
- 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
- Shared structure: object, state, next step.
- Brand tone lives in headlines and marketing copy, not in errors.
- Errors and confirmations read the same in every brand.
- Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Get started
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.
Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and 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.44:2.75rem |
| 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) | Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B |
| Text size | component.avatar.fallback.font-sizetype.body.font-sizevar(--avatar-fallback-font-size) | font.size.16:1rem |
| Text Changes with theme | component.avatar.fallback.labelcolor.text.mutedvar(--avatar-fallback-label) | Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5 |
| Font size 2 | component.avatar.fallback.font-size-2type.caption.font-sizevar(--avatar-fallback-font-size-2) | font.size.13:0.8125rem |
| 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) | Aster Lightteal.light.600:#0F766EAster Darkteal.dark.600:#7FCFC6Birch Lightpurple.light.600:#6D28D9Birch Darkpurple.dark.600:#B79DF7Coral Lightorange.light.600:#C2410CCoral Darkorange.dark.600:#F7A67F |
| Text Changes with theme | component.avatar.badge.labelcolor.text.on-actionvar(--avatar-badge-label) | Aster Lightslate-deep.light.0:#FFFFFFAster Darkslate-deep.light.900:#0F172ABirch Lightslate-deep.light.0:#FFFFFFBirch Darkslate-deep.light.900:#0F172ACoral Lightslate-deep.light.0:#FFFFFFCoral Darkslate-deep.light.900:#0F172A |
| Focus ring Changes with theme | component.avatar.badge.focus-ringcolor.surface.canvasvar(--avatar-badge-focus-ring) | Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617 |
| Group | ||
| Focus ring Changes with theme | component.avatar.group.focus-ringcolor.surface.canvasvar(--avatar-group-focus-ring) | Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617 |
| Count size | component.avatar.group.count.sizesize.control.defaultvar(--avatar-group-count-size) | size.44:2.75rem |
| 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) | Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B |
| Count font size | component.avatar.group.count.font-sizetype.body.font-sizevar(--avatar-group-count-font-size) | font.size.16:1rem |
| Count label Changes with theme | component.avatar.group.count.labelcolor.text.mutedvar(--avatar-group-count-label) | Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5 |
| Count focus ring Changes with theme | component.avatar.group.count.focus-ringcolor.surface.canvasvar(--avatar-group-count-focus-ring) | Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617 |
| Count icon size | component.avatar.group.count.icon-sizesize.iconvar(--avatar-group-count-icon-size) | size.16:1rem |