miladjoodi

Avatar

Component

About

A user profile image with a text fallback, plus badge, grouping and size variants for stacking multiple avatars together.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Avatar to your project and fits it to your theme.

Code

How Avatar is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarGroup,
  AvatarGroupCount,
  AvatarImage,
} from "@/components/ui/avatar";

export default function AvatarDemo() {
  return (
    <div
      dir="rtl"
      className="flex flex-row flex-wrap items-center justify-center gap-6 md:gap-12"
    >
      <Avatar>
        <AvatarImage
          src="https://cdn.21st.dev/assets/localized/513d06f542692036ff0bb17938f04b3efd60567ba2cae08049469d21f18e0524.jpg"
          alt="@shadcn"
          className="grayscale"
        />
        <AvatarFallback>ش‌ک</AvatarFallback>
      </Avatar>
      <Avatar>
        <AvatarImage
          src="https://cdn.21st.dev/assets/localized/8dcdb391f1f8f6610d31a9a3e06733fec308be75732571ccc6d5ce634c695382.png"
          alt="@evilrabbit"
        />
        <AvatarFallback>ش‌ب</AvatarFallback>
        <AvatarBadge className="bg-green-600 dark:bg-green-800" />
      </Avatar>
      <AvatarGroup className="grayscale">
        <Avatar>
          <AvatarImage
            src="https://cdn.21st.dev/assets/localized/513d06f542692036ff0bb17938f04b3efd60567ba2cae08049469d21f18e0524.jpg"
            alt="@shadcn"
          />
          <AvatarFallback>ش‌ک</AvatarFallback>
        </Avatar>
        <Avatar>
          <AvatarImage
            src="https://cdn.21st.dev/assets/localized/3a31d3d0c3bb2074929755298773d14e53048a8a85abbc0c944fb19fc65106bf.png"
            alt="@maxleiter"
          />
          <AvatarFallback>م‌ل</AvatarFallback>
        </Avatar>
        <Avatar>
          <AvatarImage
            src="https://cdn.21st.dev/assets/localized/8dcdb391f1f8f6610d31a9a3e06733fec308be75732571ccc6d5ce634c695382.png"
            alt="@evilrabbit"
          />
          <AvatarFallback>ش‌ب</AvatarFallback>
        </Avatar>
        <AvatarGroupCount>+۳</AvatarGroupCount>
      </AvatarGroup>
    </div>
  );
}

Dependencies

More by miladjoodi

View all
  • Image Diff Slider

    Image Diff Slider

    36
  • Empty State

    Empty State

  • Phone Input

    Phone Input

  • Button

    Button

  • Item

    Item

  • Signature Pad

    Signature Pad

  • Hover Card

    Hover Card

  • File Upload

    File Upload