Avatar components

FREE

Free and open-source React avatar components built for modern applications and websites. These avatars are built using React Aria and styled with Tailwind CSS.

Olivia Rhye

Olivia Rhye

olivia@untitledui.com

Installation

You can add this avatar component using our CLI or manually:

npx untitledui@latest add avatar

Avatar examples

Below are examples and variations of this avatar component:

Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye

Border

Use the border boolean prop to add an outer border around the avatar, helping it stand out against busy or low-contrast backgrounds.

Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye
Olivia Rhye

Status indicator

Status indicators are a common way to show the online or offline status of a user or connection. They can be used to indicate whether a user is online or offline.

Our avatar component provides a status prop that allows you to easily add status indicators to your avatars. The status prop accepts the following values: online and offline.

Company logos or avatar badges are another way to add additional information to your avatars. They can be used to display the company logo, the user's role, or any other information you want to display.

Our avatar component provides a badge prop that allows you to easily add company logos to your avatars. The badge prop accepts a React node and will be displayed in the top-right corner of the avatar. We recommend using the AvatarCompanyIcon component to easily add a company logo with predefined styles and sizes to your avatars.

Verified badge

Verified badges are quite common in any modern application. They indicate whether a user is verified and trustworthy.

Our avatar component provides a verified boolean prop that allows you to easily add styled verified badges to your avatars.

Placeholder

Avatar components should be built with common edge cases in mind. For example, what should happen if a user has no avatar, or if the provided image has failed to load?

Our avatar components are designed to be robust and handle common edge cases. For example, if no image is provided, or if the image fails to load, the component will automatically display a placeholder icon.

To change the placeholder, you can use the placeholder and placeholderIcon props. You can pass an icon (e.g., any icon from @untitledui/icons) to the placeholderIcon prop, and it will be displayed in the center of the avatar with matching styles. If you would like something more custom, you can also pass a React node to the placeholder prop.

Initials

Similar to the placeholder, you can also use the initials prop to display the user's initials when no image is available.

OR
OR
OR
OR
OR
OR

Label group

Avatar label groups are a great way to display additional information about a user. They can be used to display the user's name, email, and any other information you want to display.

Olivia Rhye

Olivia Rhye

olivia@untitledui.com

Olivia Rhye

Olivia Rhye

olivia@untitledui.com

Olivia Rhye

Olivia Rhye

olivia@untitledui.com

Group

Group avatars are also quite common in modern applications. They can be used to display a group of users or entities that belong to the same group.

To build a group of avatars, you can easily use our Avatar and AvatarAddButton components. Just place them in a flex container with appropriate spacing and you're good to go.

Olivia Rhye
Phoenix Baker
Lana Steiner
Demi Wilkinson
Candice Wu
Natali Craig
Drew Cano
Orlando Diggs
Andi Lane
Kate Morrison
+5
Olivia Rhye
Phoenix Baker
Lana Steiner
Demi Wilkinson
Candice Wu
Natali Craig
Drew Cano
Orlando Diggs
Andi Lane
Kate Morrison
+5
Olivia Rhye
Phoenix Baker
Lana Steiner
Demi Wilkinson
Candice Wu
Natali Craig
Drew Cano
Orlando Diggs
Andi Lane
Kate Morrison
+5
Olivia Rhye
Olivia Rhye
Olivia Rhye

Profile photo placeholder

Profile photo placeholders function the same way as the regular placeholder in our Avatar component. They will be displayed if no image is provided, or if the image fails to load.

Profile photo initials

Profile photo initials function the same way as the regular initials in our Avatar component. They will be displayed if no image is provided, or if the image fails to load.

API reference

Avatar

Import Avatar from @/components/base/avatar/avatar. Renders a <div> element.

Avatar props
PropTypeDefaultDescription
size
"xs""sm""md""lg""xl""2xl"
"md"The dimensions of the avatar, which also scale the initials, placeholder icon and status indicator.
classNamestring—The class name for the outer wrapper of the avatar.
contentClassNamestring—The class name for the main child of the avatar.
srcstring | null—The URL of the avatar image. Falls back to the initials, placeholder icon or placeholder if it is missing or fails to load.
altstring—The alternative text for the avatar image.
contrastBorderboolean—Display an inner contrast border around the avatar image.
roundedbooleantrueWhether the avatar should be rounded.
borderboolean—Display an outer border around the avatar.
badgeReactNode—Display a badge (i.e. company logo).
status
"online""offline"
—Display a status indicator.
verifiedbooleanfalseDisplay a verified tick icon.
countnumber—Display a count badge.
initialsstring—The initials of the user to display if no image is available.
placeholderIconFC<{ className?: string; }>—An icon to display if no image is available.
placeholderReactNode—A placeholder to display if no image is available.
focusablebooleanfalseWhether the avatar should show a focus ring when the parent group is in focus. For example, when the avatar is wrapped inside a link.

AvatarLabelGroup

Import AvatarLabelGroup from @/components/base/avatar/avatar-label-group. Renders a <figure> element.

AvatarLabelGroup props
PropTypeDefaultDescription
size* (required)
"sm""md""lg"
—The dimensions of the avatar, which also set the text size of the title and subtitle.
title* (required)ReactNode—The primary line of text shown next to the avatar, such as a person's name.
subtitle* (required)ReactNode—The secondary line of text shown below the title. Truncates when it overflows.
roundedboolean—Whether the avatar is a circle rather than a rounded square.
avatarClassNamestring—The class name applied to the avatar, while className styles the whole group.
classNamestring—The class name for the outer wrapper of the avatar.
contentClassNamestring—The class name for the main child of the avatar.
srcstring | null—The URL of the avatar image. Falls back to the initials, placeholder icon or placeholder if it is missing or fails to load.
altstring—The alternative text for the avatar image.
contrastBorderboolean—Display an inner contrast border around the avatar image.
borderboolean—Display an outer border around the avatar.
badgeReactNode—Display a badge (i.e. company logo).
status
"online""offline"
—Display a status indicator.
verifiedbooleanfalseDisplay a verified tick icon.
countnumber—Display a count badge.
initialsstring—The initials of the user to display if no image is available.
placeholderIconFC<{ className?: string; }>—An icon to display if no image is available.
placeholderReactNode—A placeholder to display if no image is available.
focusablebooleanfalseWhether the avatar should show a focus ring when the parent group is in focus. For example, when the avatar is wrapped inside a link.

AvatarProfilePhoto

Import AvatarProfilePhoto from @/components/base/avatar/avatar-profile-photo. Renders a <div> element.

AvatarProfilePhoto props
PropTypeDefaultDescription
size
"sm""md""lg"
"md"The dimensions of the photo, which also scale the surrounding ring, initials and status indicator.
classNamestring—The class name for the outer wrapper of the avatar.
contentClassNamestring—The class name for the main child of the avatar.
srcstring | null—The URL of the avatar image. Falls back to the initials, placeholder icon or placeholder if it is missing or fails to load.
altstring—The alternative text for the avatar image.
contrastBorderboolean—Display an inner contrast border around the avatar image.
roundedbooleantrueWhether the avatar should be rounded.
borderboolean—Display an outer border around the avatar.
badgeReactNode—Display a badge (i.e. company logo).
status
"online""offline"
—Display a status indicator.
verifiedbooleanfalseDisplay a verified tick icon.
countnumber—Display a count badge.
initialsstring—The initials of the user to display if no image is available.
placeholderIconFC<{ className?: string; }>—An icon to display if no image is available.
placeholderReactNode—A placeholder to display if no image is available.
focusablebooleanfalseWhether the avatar should show a focus ring when the parent group is in focus. For example, when the avatar is wrapped inside a link.

FAQs

Please refer to our frequently asked questions page for more.

If src is empty or the image fails to load, Avatar falls back in this order: initials, then the placeholderIcon component, then the placeholder element, and finally a default User01 icon.

Set status to "online" or "offline". It renders a dot in the bottom-right corner, green for "online" and neutral gray for "offline", sized to match the avatar.

Yes. Use verified for a verified tick, count for a number badge, or badge for any element such as a company logo. Only one indicator renders at a time, picked in the order status, verified, count, badge, so setting status hides the other three.

Avatar accepts a size of "xs", "sm", "md", "lg", "xl" or "2xl", defaulting to "md". AvatarLabelGroup and AvatarProfilePhoto only accept "sm", "md" and "lg", and both type size as required.

Pass rounded={false}. The avatar then uses small rounded corners instead of a full circle.

Place the avatars in a flex -space-x-2 container and give each one className="ring-[1.5px] ring-bg-primary" so they separate visually, as the group example does. To end the stack with an add button, use AvatarAddButton from @/components/base/avatar/base-components, which takes a required size of "xs", "sm" or "md" and a title (default "Add user") used for its tooltip and aria-label.

Set focusable on the Avatar and add the group class to the link around it. The ring is styled with group-focus-visible, so it only appears when that parent receives keyboard focus.