Skip to main content

Avatar

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

In Content first

See it live​

Start Storybook to see it live: npm run storybook

When 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: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.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.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
Avatar
Sizecomponent.avatar.sizesize.control.defaultvar(--avatar-size)size.48:3rem
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)Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24
Text sizecomponent.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 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)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 sizecomponent.avatar.group.count.sizesize.control.defaultvar(--avatar-group-count-size)size.48:3rem
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)Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24
Count font sizecomponent.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 sizecomponent.avatar.group.count.icon-sizesize.iconvar(--avatar-group-count-icon-size)size.16:1rem