Skip to content
New

Avatar

A person's picture, with initials while it loads or when it fails. Round, or square in Iwa; stacks into a group.

NUSASH
NUSHSAKK+3

Installation

Terminal
npx rasengan-ui add avatar

Or with the shadcn CLI, from the registry:

Terminal
npx shadcn@latest add https://ui.rasengan.dev/r/base/avatar.json

Usage

app/author.tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
 
export function Author() {
  return (
    <Avatar>
      <AvatarImage src="/avatars/sakura.png" alt="Sakura Haruno" />
      <AvatarFallback>SH</AvatarFallback>
    </Avatar>
  );
}

Sizes and groups

size is sm, default, lg or xl; the initials follow it.

NUNUNUNU

AvatarGroup overlaps its avatars, and AvatarGroupCount ends the stack with the number left out.

<AvatarGroup>
  <Avatar><AvatarFallback>NU</AvatarFallback></Avatar>
  <Avatar><AvatarFallback>SU</AvatarFallback></Avatar>
  <AvatarGroupCount>+3</AvatarGroupCount>
</AvatarGroup>

Villages

Round with the pill radius, so square in Iwa; the fallback sits on the muted surface, opaque so a stack never shows through in Kiri.

Konoha · light
NUSASH
NUSHSAKK+3
Konoha · dark
NUSASH
NUSHSAKK+3
Kiri · light
NUSASH
NUSHSAKK+3
Kiri · dark
NUSASH
NUSHSAKK+3
Iwa · light
NUSASH
NUSHSAKK+3
Iwa · dark
NUSASH
NUSHSAKK+3

Accessibility

  • The image needs an alt naming the person; the fallback shows only when the image is missing or still loading.
  • In a group, name the people in the text around it, or give the group an aria-label.

API reference

The parts of Base UI's Avatar:

PartNotes
Avatarsize: "sm" | "default" | "lg" | "xl"; avatarVariants({ size }) returns its classes
AvatarImagesrc, alt, onLoadingStatusChange
AvatarFallbackdelay before it shows
AvatarGroup, AvatarGroupCount<div> and <span>