Avatar

A customizable avatar component with support for images, initials, and status indicators.

avatar
John Doe

Installation

1. Dependencies

npm install clsx tailwind-merge

2. Paste inside @/lib/utils.ts

import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: Parameters<typeof clsx>) {
  return twMerge(clsx(...inputs));
}

3. Copy Avatar Code

Loading...

Copy Avatar Code

Avatar Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedThe child components to render inside the avatar container, such as AvatarImage or AvatarTooltip.
classNamestringNoundefinedAdditional class names for custom styling of the avatar container.

AvatarImage Props

NameTypeRequiredDefaultDescription
sizenumberYesundefinedThe size of the avatar image in pixels.
srcstringNoundefinedThe source URL of the avatar image.
fallbackstringNoundefinedFallback text or initials to display when the image is not available.
classNamestringNoundefinedAdditional class names for custom styling of the avatar image.

AvatarTooltip Props

NameTypeRequiredDefaultDescription
textstringYesundefinedThe text to display inside the tooltip.
position"top" | "bottom" | "left" | "right"No"bottom"The position of the tooltip relative to the avatar.
classNamestringNoundefinedAdditional class names for custom styling of the tooltip.