In some products, you might need to show a badge on the right corner of the
avatar. We call this a badge. Here's an example that shows if the user is
online:
<Stackdirection="row"spacing={4}>
<Avatar>
<AvatarBadgeboxSize="1.25em"bg="green.500"/>
</Avatar>
{/* You can also change the borderColor and bg of the badge */}
Added getInitials prop to allow users to manage how initials are generated
from name. By default we merge the first characters of each word in the name
prop.
The Avatar component composes Box component so you can pass props for Box.
Name
Type
Description
Default
colorScheme
string
-
getInitials
((name: string) => string)
Function to get the initials to display
-
icon
React.ReactElement
The default avatar used as fallback when `name`, and `src`
is not specified.
-
loading
"eager" | "lazy"
Defines loading strategy
-
name
string
The name of the person in the avatar.
- if `src` has loaded, the name will be used as the `alt` attribute of the `img`
- If `src` is not loaded, the name will be used to create the initials
-
onError
(() => void)
Function called when image failed to load
-
showBorder
boolean
If `true`, the `Avatar` will show a border around it.
Best for a group of avatars
-
size
string
The size of the avatar.
-
src
string
The image url of the `Avatar`
-
srcSet
string
List of sources to use for different screen resolutions