Avatar

PreviousNext

A component that displays a user avatar, supporting images or initials with customizable styling

Avatar using text:
JD
Avatar using image:
John Doe
Avatar using icon:
JD
'use client';

import { Avatar } from '@/ui/Avatar';
import { Icon } from '@clubmed/trident-icons';

export function AvatarDemo() {
  return (
    <div>
      Avatar using text:
      <Avatar alt="John Doe" />
      Avatar using image:
      <Avatar alt="John Doe" src="https://randomuser.me/api/portraits/men/75.jpg" />
      Avatar using icon:
      <Avatar alt="John Doe">
        <Icon name="PeopleSingle" width="24px" />
      </Avatar>
    </div>
  );
}

Installation

npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/avatar.json

Usage

import Avatar from '@/docs/lib/ui/avatar';
 
export function Component() {
  return <Avatar alt="John Doe" src="/path/to/image.jpg" />;
}

API Reference

Avatar

PropTypeDefaultDescription
altstringundefinedAlt text for the image, or text used to generate initials when no image is provided
srcstring | undefinedundefinedThe source URL for the avatar image
srcSetstring | undefinedundefinedThe srcSet attribute for responsive images
classNamestringundefinedAdditional CSS classes. Defaults include rounded-full, text-black, and bg-saffron
styleCSSProperties{ width: "48px", height: "48px" }Custom inline styles. Default size is 48x48 pixels
childrenReactNodeundefinedOptional children elements to overlay on the avatar

Notes