Avatar

An image with a fallback for representing a user.

The Avatar displays a user image and falls back to initials when the image is unavailable.

Preview

CN

Installation

$ npx shadcn@latest add https://spark-ui-olive.vercel.app/r/avatar.json

Usage

import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from "@/components/avatar";
export default function AvatarDemo() {
  return (
    <Avatar>
      <AvatarImage src="https://github.com/shadcn.png" alt="Shadcn" />
      <AvatarFallback>CN</AvatarFallback>
    </Avatar>
  );
}

Properties

PropTypeDefaultDescription
size"sm" | "default" | "lg""default"Size of the avatar.
classNamestringAdditional CSS classes.