Command Palette

Search for a command to run...

Avatar

An image element with a fallback for representing the user.

CN

Installation

npm i @radix-ui/react-avatar

Usage

1 2 3 4 5 6 7 8 9 10 import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" export function AvatarDemo() { return ( <Avatar> <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" /> <AvatarFallback>CN</AvatarFallback> </Avatar> ) }

Examples

With Fallback

Initial Fallback

JD

Custom Color

AB

With Icon

Different Sizes

Small

SM

Default

MD

Large

LG

Extra Large

XL

Props

ComponentPropsDescription
AvatarAvatarPrimitive.AvatarPropsThe root component for the avatar.
AvatarImageAvatarPrimitive.AvatarImageProps
src: string
alt: string
The image displayed in the avatar.
AvatarFallbackAvatarPrimitive.AvatarFallbackPropsThe fallback element displayed when the image fails to load.