Equality
Equality

Avatar

Avatar with sizes and variants

View Markdown

Overview

Avatars represent a user or entity with a profile image and initials fallback.

Usage

Import the component:

import { Avatar, AvatarImage, AvatarFallback } from "@eqtylab/equality";

Basic usage with an image and fallback:

<Avatar>
  <AvatarImage src="/path/to/image.jpg" alt="User name" />
  <AvatarFallback>AB</AvatarFallback>
</Avatar>

Variants

Image

When a valid src is provided to AvatarImage, the avatar displays the image.

Fallback

When no image is provided or the image fails to load, AvatarFallback is displayed instead, typically showing initials.

Sizes

The size prop controls the dimensions of the avatar.

<Avatar size="sm">...</Avatar>
<Avatar size="md">...</Avatar>
<Avatar size="lg">...</Avatar>
<Avatar size="xl">...</Avatar>

Shape

The shape prop controls the border radius of the avatar.

Circle (Default)

Square

<Avatar shape="circle">...</Avatar>
<Avatar shape="square">...</Avatar>

Slots

NameDescription
childrenAccepts AvatarImage and AvatarFallback as children

Props

Avatar

NameDescriptionTypeDefaultRequired
sizeThe size of the avatarsm, md, lg, xlmd
shapeThe shape of the avatarcircle, squarecircle

AvatarImage

NameDescriptionTypeDefaultRequired
srcThe image source URLstring-
altAccessible alt text for imagestring-

AvatarFallback

No properties, but needs child content to render.