Avatar is used to represent a user. Every Avatar image has a subtle color wash.

also known as Pinner rep, Persona, User Image, Identifier, Identicon

Figma:

Responsive:

Adaptive:

A11y:

Props

Component props
Name
Type
Default
name
Required
string
-

The name of the user. This is used for the placeholder treatment if an image is not available.

accessibilityLabel
string
-

String that clients such as VoiceOver will read to describe the element. Will default to name prop if not provided.

outline
boolean
-

Adds a white border around Avatar so it's visible when displayed on other images.

size
"xs" | "sm" | "md" | "lg" | "xl" | "fit"
-

xs: 24px, sm: 32px, md: 48px, lg: 64px, xl: 120px. If size is fit, Avatar will fill 100% of the parent container width.

src
string
-

The URL of the user's image.

verified
boolean
-

Used to indicate if the user is verified.

Usage guidelines

When to use
  • To reflect a person, company or brand within the product.
When not to use
  • To represent a group of people, companies and/or brands. Use AvatarGroup instead.

Best Practices

Do

Use the default alternative if no image source is available. This will be the first character of the provided name.

Don't

Use alternative graphics or icons

Do

Use round Avatars in the appropriate size for your need. Learn more about avatar sizing.

Don't

Scale or change the shape of Avatar. Instead use the designated Avatar sizes and style.

Do

Use Avatar to represent a person, organization or group ( Avatar Group).

Don't

Use Avatar to represent metaphorical ideas, like a Board. Instead, consider an icon or the appropriate interactive component.

Do

Use the collaborator’s name nearby or in an alternative view if possible.

Don't

Place elements like washes, text or icons over Avatars.

Accessibility

The avatar should have a text equivalent. Use the accessibilityLabel prop to ensure there is a text description for the image. The VoiceOver description will default to the name prop if accessibilityLabel is not provided.

Make sure that the alternative text properly describes the information and function of the avatar image(s). Depending on the situation, it may be helpful to state the collaborator or company name and/or their verification status.

Localization

Be sure to localize all text strings. Note that localization can lengthen text by 20 to 30 percent.

Variants

Fixed sizes

There are 5 sizes available for Avatar. For certain designs you may need a container-based size.

import { Avatar, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      gap={4}
      height="100%"
      justifyContent="center"
      width="100%"
      wrap
    >
      <Avatar
        name="Keerthi"
        size="xs"
        src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
      />
      <Avatar
        name="Keerthi"
        size="sm"
        src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
      />
      <Avatar
        name="Keerthi"
        size="md"
        src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
      />
      <Avatar
        name="Keerthi"
        size="lg"
        src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
      />
      <Avatar
        name="Keerthi"
        size="xl"
        src="https://i.ibb.co/ZfCZrY8/keerthi.jpg"
      />
    </Flex>
  );
}

Container-based sizes

Avatars without a size prop will expand to fit the width of their parent container. A common use case is to achieve column-based sizing.

Resize the browser to see these Avatar change to match the width of the Column they have been placed in.

import { Avatar, Box, Flex } from 'gestalt';

export default function Example() {
  return (
    <Box maxWidth={900} width="100%">
      <Flex>
        <Box width={40}>
          <Avatar name="Julia" />
        </Box>
        <Box column={2}>
          <Avatar name="Julia" />
        </Box>
        <Box column={4}>
          <Avatar name="Keerthi" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />
        </Box>
      </Flex>
    </Box>
  );
}

Without an image

If there is no image source provided to the Avatar, the first character of
the name provided will be used as a placeholder.

import { Avatar, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <Avatar name="Keerthi" size="lg" />
    </Flex>
  );
}

Verified

For users with verified accounts, use the verified prop to add a checkmark. Be sure to update the accessibilityLabel to include this information as well.

import { Avatar, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <Avatar
        accessibilityLabel="Shanice, Verified account"
        name="Shanice"
        size="lg"
        src="https://i.ibb.co/7tGKGvb/shanice.jpg"
        verified
      />
    </Flex>
  );
}

Component quality checklist

Component quality checklist
Quality item
Status
Status description
Figma Library
Ready
Component is available in Figma for web and mobile web.
Responsive Web
Ready
Component responds to changing viewport sizes in web and mobile web.

Internal documentation

AvatarGroup
AvatarGroup is the ideal component in cases where multiple people/brands need to be displayed.