Skip to content

Avatar

The Avatar component provides a way to represent an image with a fallback for when the image cannot be loaded. It supports displaying initials derived from the name prop or an Avatar Icon if no name or src is provided.

Installation

import { Avatar } from '@harnessio/ui'
// ...
return (
<Avatar name="John Doe" src="/avatar.png" />
)

Sizes

The Avatar component supports four sizes: xs, sm, md, and lg. The default size is sm.

Shapes

By default the Avatar is a rounded square. Pass rounded to render it as a circle.

No initials

In case you want the fallback string to be without initials, pass the noInitials prop.

Custom Icon

You can display a custom icon instead of initials or the default user icon using the icon prop.

With Tooltip

Use AvatarWithTooltip to display a tooltip on hover.