Skip to content

Content

Avatar

Bundle size
3.76 KB
3.2.3

A fallback image element to represent a user.

This component is an expansion of the Avatar developed and maintained by Radix UI.

You can control the appearance of the avatar through the shape and size properties. This component also provides two types of fallbacks: one that displays the user’s initials and another that shows a default icon when the image is unavailable.

Terminal window
pnpm add @inpulse-ui/avatar

Contains all the parts of an avatar.

PropTypeDefault ValueRequired
asChildbooleanfalseNo
sizeenumNo
shapeenumNo

The image to render. By default it will only render when it has loaded. You can use the onLoadingStatusChange handler if you need more control.

PropTypeDefault ValueRequired
asChildbooleanfalseNo
onLoadingStatusChangefunction-No

An element that renders when the image hasn’t loaded. This means whilst it’s loading, or if there was an error. If you notice a flash during loading, you can provide a delayMs prop to delay its rendering so it only renders for those with slower connections. The following fallback components are available: AvatarTextFallback and AvatarIconFallback.

PropTypeDefault ValueRequired
asChildbooleanfalseNo
delayMsnumber-No

Inside the Avatar component, you can use the AvatarImage to display an image and the AvatarTextFallback or AvatarIconFallback to display a fallback element when the image is not available or still loading.

<Avatar>
<AvatarImage src="https://github.com/josantana.png" />
<AvatarTextFallback>JS</AvatarTextFallback>
</Avatar>

By default, all avatars are round.

To get a squared avatar, you can change the shape property to square.

JS

If no image or fallback text is provided for whatever reason, the icon will be displayed.

You can use custom icons instead of the one provided by AvatarIconFallback. To do this, simply pass the desired icon as a child of that element.

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.