MA

Avatar Component

An image element with a fallback for representing the user.

  • Displays user images with elegant fallback options
  • Supports different sizes
  • Offers customizable shapes (rounded, square)

Installation

The Avatar component is part of our UI library. You can import it directly from the components directory.


Usage

Here is how to use the avatar in your project.

React TSX
1import {
2  Avatar,
3  AvatarImage,
4  AvatarFallback
5} from "@/components/modern-ui/avatar"

React TSX
1<Avatar>
2  <AvatarImage src="https://example.com/user.jpg" alt="User" />
3  <AvatarFallback>JD</AvatarFallback>
4</Avatar>

Examples

Basic Avatar

MA

Avatar with Fallback

JD

Avatar Sizes

MAMAMA

API Reference

Avatar

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReactNode-AvatarImage and AvatarFallback components

AvatarImage

PropTypeDefaultDescription
srcstring-URL of the avatar image
altstring-Alt text for the avatar image
classNamestring-Additional CSS classes

AvatarFallback

PropTypeDefaultDescription
delayMsnumber600Delay before showing fallback when image fails to load
classNamestring-Additional CSS classes
childrenReactNode-Content to display as fallback

AvatarGroup

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReactNode-Avatar components
maxnumber-Maximum number of avatars to display before showing a count