darshan-rajadhyaksha

Avatar

Component

About

A user/entity avatar that renders a profile image with automatic fallback to initials derived from a name, with color, rounded-shape and size variants. Ported from the RockSolid (SolidJS) UI library by Darshan Rajadhyaksha to React.

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

export default function AvatarCustomizationDemo() {
  return (
    <Avatar
      src="https://cdn.21st.dev/assets/mirror/be/be1b67757a13dfec4386e8627236a7194c6bcfb07502dbd82f727f6ccac46bcd.jpg"
      alt="User avatar"
      className="size-12 border border-2 border-blue-500"
      slotProps={{
        img: {
          loading: "lazy",
        },
      }}
    />
  );
}

Dependencies

More by darshan-rajadhyaksha

View all
  • Backdrop

    Backdrop

    1
  • Switch

    Switch

  • Chip

    Chip

  • Progress Bar

    Progress Bar

  • Accessible Dialog

    Accessible Dialog

  • Input

    Input

  • Card Content

    Card Content

  • Breadcrumbs

    Breadcrumbs