Cnippet

Avatar

Component

About

An avatar component with image and text fallback for displaying user profile pictures, built on Base UI.

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, AvatarFallback, AvatarImage } from "@/components/ui/avatar";

export default function AvatarDemo() {
  return (
    <div className="flex min-h-64 w-full items-center justify-center gap-6 bg-background p-8">
      <Avatar className="size-12">
        <AvatarImage
          alt="Luke Tracy"
          src="https://cdn.21st.dev/assets/mirror/ad/adfa33eea333b2ca8227b64fc1555b8993a79f63fed7941677169821a9fefdba.jpg"
        />
        <AvatarFallback>LT</AvatarFallback>
      </Avatar>
      <Avatar className="size-12">
        <AvatarImage src="/broken-image.png" alt="User avatar" />
        <AvatarFallback>JD</AvatarFallback>
      </Avatar>
    </div>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    683
  • Aero Hero-3

    Aero Hero-3

    558
  • Features

    Features

    510
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    487
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    465
  • Blogs

    Blogs

    396
  • Aero Hero-1

    Aero Hero-1

    356