120k

Avatar

An image element with a fallback for representing the user.

Installation

pnpm dlx shadcn@latest add @force-ui-ember/avatar

Usage

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

Composition

Use the following composition to build an Avatar:

Avatar
├── AvatarImage
└── AvatarFallback

Examples

Basic

A basic avatar component with an image and a fallback.

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

API Reference

Avatar

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

PropTypeDefault
@classstring-

AvatarImage

The AvatarImage component displays the avatar image.

PropTypeDefault
@srcstring-
@altstring-
@classstring-

AvatarFallback

The AvatarFallback component displays a fallback when the image fails to load.

PropTypeDefault
@classstring-