Avatar

Avatar is a component that displays a profile picture or an icon with initials representing a user.

Usage

import { Avatar, AvatarGroup } from "@yamada-ui/react"
<Avatar />
<AvatarGroup.Root>
  <AvatarGroup.Item />
</AvatarGroup.Root>

Change Variant

Change Size

Change Shape

Display Initials

When you set a string to name, an icon with the user's initials will be displayed.

Display an Image

If you want to display an image in the avatar, set the path to src.

Fallback

There are two fallbacks if the loading of src fails:

  • If name is provided: It uses an icon with the user's initials
  • If name is not provided: It uses the default avatar icon.

Customize the Fallback

Here is an example of customizing the fallback icon and background color.

Use random color

Grouping

If you want to control the number of avatars displayed, specify a number with max. If there are more avatars than the specified number, it truncates and displays the remaining avatars as +X.

Props

Accessibility

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
AvatarImagealtAlternative text for the avatar image. The component uses the name prop as the value for the alt attribute; if name is not provided, it uses the alt prop value instead.
AvatarFallbackrole="img"Indicates that this is an image.
aria-labelThis is set when fallback is not provided. Sets the value of name or alt if provided. Otherwise, sets "Avatar Icon".
AvatarGroup.Rootrole="group"Indicates that it is a group.