Skip to main content
Login

Sign in to access your account

Avatar - National Design System

A round picture of a person or an account, with a photo, initials or an icon.

Overview

An avatar is an element with the nds-avatar class that holds one item: a photo (<img>), initials (nds-label) or an icon. It is round by default. The element can be a <div>, a link or a button. Several avatars sit together in an nds-avatar-group, spaced apart or stacked so they overlap.

Pick another component when:

  • the picture sits beside a name and a role: Persona
  • the icon marks a status or a type, not a person: Featured Icons

Markup

Preview
<div class="nds-avatar nds-xl"> <i class="nds-icon nds-icon-avatar" aria-hidden="true"></i> </div>

Built-in Features

  • Pure CSS

    Avatars need no JavaScript. They show at the first paint, from the markup alone.

  • Seven Sizes

    From 24px (XS) to 120px (3XL). The initials are a third of the size and the icon is half, so both scale with it.

  • Any Element

    The same class works on a <div>, a link or a button. A link avatar keeps the avatar colors, not the link color.

  • Group Layout

    A size class on the group sets the size of every avatar in it, and the gap grows with the size.

  • High Contrast Ring

    In high contrast mode, every avatar gets a solid ring inside its edge, so a photo stays apart from the page.

  • Broken Photo

    When a photo does not load, the avatar shows the person icon in place of the broken-image mark and the alt text. Screen readers still read the alt text. Safari shows its own small broken-image mark and no text.

Best Practices

  • Show a photo when one is available. When there is none, show two letters from the person’s name.
  • Use an icon avatar for an anonymous user or a system account, where no one is named.
  • Write alt text that names the person. Use alt="" only when the name shows in text next to the avatar.
  • Give a link or button avatar a name. A photo names it through its alt. An avatar with initials or an icon needs aria-label, such as aria-label="Open the user menu".
  • Pick the size by place: XS or SM in a line of text or a table row, XL in a card, 3XL in a profile header.
  • In a List, leave the size class off. The list makes the avatar XL, a small list (nds-sm) LG, and a large list (nds-lg) 2XL.
  • In a group, set the size on nds-avatar-group. The group size replaces a size class on an avatar inside it.
  • Use a group to show the members of a team or the people on a task in little space.
  • End a long group with an initials avatar that counts the people it does not show, such as +9.

API

CSS Custom Properties

Property Default Controls
--avatar-size 40px Width and height. It wins over the size classes. Set it on the avatar, or on a parent to size every avatar inside
--avatar-gap 6px Space between the avatars of a group. A stacked group overlaps them by twice this value. Set it on the group

Tokens

Set a token at :root, or on a wrapper to reach every avatar inside it. Give a token with a Dark mode value a dark override too: see Tokens. The border is the ring of a 3XL avatar and of each avatar in a stacked group.

Source: the avatar group in _sass/tokens/_components.scss.

TokenPreviewValue
--avatar-background
var(--colors-neutral-100)
Dark mode var(--colors-neutral-700)
--avatar-color
var(--icon-default)
Dark mode var(--colors-neutral-300)
--avatar-border
var(--colors-base-white)
Dark mode var(--colors-neutral-800)
Last Modified Date: 08/11/2026 - 09:40 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks