Skip to content

Avatar

<bh-avatar> | BharatAvatar

The Avatar component displays user profile images with various shapes and sizes. It automatically handles missing images by providing default avatars.

Basic Usage

Sizes

The Avatar component supports the below three predefined sizes:

Shapes

The Avatar component supports two shapes:

ShapeDescription
squareSquare avatar with rounded corners
circleCircular avatar

Avatar with Initials

If no image is provided, and the initials prop is set, the avatar will display the initials with a random background color and auto-scaled text size.

Custom Styling

With Specific Default Avatar

With Custom Image

Properties

PropertyTypeDescription
size  string  Avatar size ("small", "medium", "large")
shape  string  Shape of the avatar ("square", "circle")
avatarURL  string  Avatar image URL - loads default images incase no avatarURL attribute is provided
width  string  Custom width (overrides size)
height  string  Custom height (overrides size)
borderRadius  string  Custom border radius (overrides shape)
border  string  Style border (e.g., 2px solid red)
key  number  Loads specific default animated avatar
initials  string  Generate initials based avatar, example - initials="Bharat UI" will render an avatar with initials “BU”
initialsTextSize string  Font size for initials
backgroundColor string  Background color for initials-based Avatar