Skip to main content

Avatar

A small image or initials that stand for a person or account.

In Brand expressive

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Brand expressive: Faces in quotes from customers.

  • 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​

  • Headlines are short and bold. Three to six words.
  • Verbs that move: Join, Try, Go.
  • Playful in headlines, plain in errors.
  • Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.

The labels components use, from the voice tokens:

  • content.action.commit: Go
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Explore the drop

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.

Changes with theme

Brand expressive 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.

PartIts token and the semantic it aliasesValue
Avatar
Sizecomponent.avatar.sizesize.control.defaultvar(--avatar-size)size.52:3.25rem
Cornercomponent.avatar.radiusradius.roundvar(--avatar-radius)radius.full:9999px
Fallback
Cornercomponent.avatar.fallback.radiusradius.roundvar(--avatar-fallback-radius)radius.full:9999px
Fill
Changes with theme
component.avatar.fallback.backgroundcolor.surface.sunkenvar(--avatar-fallback-background)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Text sizecomponent.avatar.fallback.font-sizetype.body.font-sizevar(--avatar-fallback-font-size)font.size.17:1.0625rem
Text
Changes with theme
component.avatar.fallback.labelcolor.text.mutedvar(--avatar-fallback-label)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
Font size 2component.avatar.fallback.font-size-2type.caption.font-sizevar(--avatar-fallback-font-size-2)font.size.14:0.875rem
Badge
Cornercomponent.avatar.badge.radiusradius.roundvar(--avatar-badge-radius)radius.full:9999px
Fill
Changes with theme
component.avatar.badge.backgroundcolor.action.primaryvar(--avatar-badge-background)Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA
Text
Changes with theme
component.avatar.badge.labelcolor.text.on-actionvar(--avatar-badge-label)Lighttaupe.light.0:#FFFFFFDarktaupe.light.900:#1F1411
Focus ring
Changes with theme
component.avatar.badge.focus-ringcolor.surface.canvasvar(--avatar-badge-focus-ring)Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09
Group
Focus ring
Changes with theme
component.avatar.group.focus-ringcolor.surface.canvasvar(--avatar-group-focus-ring)Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09
Count sizecomponent.avatar.group.count.sizesize.control.defaultvar(--avatar-group-count-size)size.52:3.25rem
Count radiuscomponent.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)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Count font sizecomponent.avatar.group.count.font-sizetype.body.font-sizevar(--avatar-group-count-font-size)font.size.17:1.0625rem
Count label
Changes with theme
component.avatar.group.count.labelcolor.text.mutedvar(--avatar-group-count-label)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
Count focus ring
Changes with theme
component.avatar.group.count.focus-ringcolor.surface.canvasvar(--avatar-group-count-focus-ring)Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09
Count icon sizecomponent.avatar.group.count.icon-sizesize.iconvar(--avatar-group-count-icon-size)size.20:1.25rem