For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
119

Avatar

An image element with a fallback for representing the user.

CNER
CNLRER
+3
import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarGroup,
  AvatarGroupCount,

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/avatar.json

Usage

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
<Avatar>
  <AvatarImage src="https://github.com/shadcn.png" />
  <AvatarFallback>CN</AvatarFallback>
</Avatar>

Composition

Use the following composition to build an Avatar:

Avatar
├── AvatarImage
├── AvatarFallback
└── AvatarBadge

Use the following composition to build an AvatarGroup:

AvatarGroup
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
└── AvatarGroupCount

Basic

A basic avatar component with an image and a fallback.

CN
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from "@/components/ui/avatar";

Badge

Use the AvatarBadge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.

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

Use the className prop to add custom styles to the badge such as custom colors, sizes, etc.

<Avatar>
  <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
  <AvatarFallback>CN</AvatarFallback>
  <AvatarBadge className="bg-green-600 dark:bg-green-800" />
</Avatar>

Badge with Icon

You can also use an icon inside <AvatarBadge>.

PP
import { PlusIcon } from "lucide-react";

import {
  Avatar,
  AvatarBadge,
  AvatarFallback,

Avatar Group

Use the AvatarGroup component to add a group of avatars.

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

Avatar Group Count

Use <AvatarGroupCount> to add a count to the group.

CNLRER
+3
import {
  Avatar,
  AvatarFallback,
  AvatarGroup,
  AvatarGroupCount,
  AvatarImage,

Avatar Group with Icon

You can also use an icon inside <AvatarGroupCount>.

CNLRER
import { PlusIcon } from "lucide-react";

import {
  Avatar,
  AvatarFallback,
  AvatarGroup,

Sizes

Use the size prop to change the size of the avatar.

CNCNCN
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from "@/components/ui/avatar";

You can use the Avatar component as a trigger for a dropdown menu.

"use client";

import {
  Avatar,
  AvatarFallback,
  AvatarImage,

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

CNER
CNLRER
"use client";

import * as React from "react";

import { useTranslation } from "@/components/language-selector";
import type { Translations } from "@/components/language-selector";

API Reference

Avatar

The Avatar component is the root component that wraps the avatar image and fallback.

PropTypeDefault
size"default" | "sm" | "lg""default"
classNamestring-

AvatarImage

The AvatarImage component displays the avatar image. It accepts all Base UI Avatar Image props.

PropTypeDefault
srcstring-
altstring-
classNamestring-

AvatarFallback

The AvatarFallback component displays a fallback when the image fails to load. It accepts all Base UI Avatar Fallback props.

PropTypeDefault
classNamestring-

AvatarBadge

The AvatarBadge component displays a badge indicator on the avatar, typically positioned at the bottom right.

PropTypeDefault
classNamestring-

AvatarGroup

The AvatarGroup component displays a group of avatars with overlapping styling.

PropTypeDefault
classNamestring-

AvatarGroupCount

The AvatarGroupCount component displays a count indicator in an avatar group, typically showing the number of additional avatars.

PropTypeDefault
classNamestring-

For more information about Base UI Avatar props, see the Base UI documentation.