Avatar

A person's picture, with initials as the fallback.

CDCDCD
CDNGML
+4
<Avatar.Root>
	<Avatar.Image src={user.avatarUrl} alt={user.name} />
	<Avatar.Fallback>CD</Avatar.Fallback>
</Avatar.Root>

The fallback shows while the image loads and stays if it fails, so always give one. Avatar.Group overlaps a row of them and Avatar.GroupCount closes it with an overflow count.

For a name and a role next to the picture, UserAvatar does that in one component.

API

Avatar.Root

PropTypeDefault
size"default" | "lg" | "sm""default"
classNamestring | ((state: AvatarRootState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<HTMLProps, AvatarRootState> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleCSSProperties | ((state: AvatarRootState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: avatar/components/avatar-root.tsx.

Avatar.Badge

PropTypeDefault
status"busy" | "offline" | "online"Presence dot: online reads success, busy destructive, offline muted. Colour is the only difference between them, so give the badge a label or title — a screen reader gets nothing from the hue.

Plus every <span> prop. Source: avatar/components/avatar-badge.tsx.

Avatar.Fallback

PropTypeDefault
classNamestring | ((state: AvatarFallbackState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
delaynumberHow long to wait before showing the fallback. Specified in milliseconds.
renderComponentRenderFn<HTMLProps, AvatarFallbackState> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleCSSProperties | ((state: AvatarFallbackState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: avatar/components/avatar-fallback.tsx.

Avatar.Group

PropTypeDefault
renderComponentRenderFn<HTMLProps, {}> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Plus every <div> prop. Source: avatar/components/avatar-group.tsx.

Avatar.GroupCount

PropTypeDefault
size"default" | "lg" | "sm""default"
renderComponentRenderFn<HTMLProps, {}> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Plus every <div> prop. Source: avatar/components/avatar-group-count.tsx.

Avatar.Image

PropTypeDefault
classNamestring | ((state: AvatarImageState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
onLoadingStatusChange((status: ImageLoadingStatus) => void)Callback fired when the loading status changes.
renderComponentRenderFn<HTMLProps, AvatarImageState> | ReactElement<unknown, string | JSXElementConstructor<any>>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
styleCSSProperties | ((state: AvatarImageState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.

Plus the DOM props of the element it renders. Source: avatar/components/avatar-image.tsx.