1. Docs
  2. components
  3. Avatar

Avatar

An image element with a fallback for representing the user.

Installation

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Usage

Single import

import { Avatar } from "~/components/ui/avatar";
import { Icons } from "~/components/ui/icons";
<Avatar.Root>
  <Avatar.Image src="https://github.com/fellipeutaka.png" alt="@fellipeutaka" />
  <Avatar.Fallback>FU</Avatar.Fallback>
  <Avatar.Placeholder>
    <Icons.User className="size-6" />
  </Avatar.Placeholder>
</Avatar.Root>

Multiple imports

import {
  AvatarRoot,
  AvatarFallback,
  AvatarImage,
  AvatarPlaceholder,
} from "~/components/ui/avatar";
import { Icons } from "~/components/ui/icons";
<AvatarRoot>
  <AvatarImage src="https://github.com/fellipeutaka.png" alt="@fellipeutaka" />
  <AvatarFallback>FU</AvatarFallback>
  <AvatarPlaceholder>
    <Icons.User className="size-6" />
  </AvatarPlaceholder>
</AvatarRoot>

Examples

Default

+3

API Reference

Root

Contains all the parts of an avatar.

Image

The image to render. By default it will only render when it has loaded.

Fallback

An element that renders when the image hasn't loaded. This means whilst it's loading, or if there was an error.

Placeholder

An element that renders when the image is loading.