Logobaseui-cn

Avatar

An image element with a fallback for representing the user.

displayprimitive
Loading preview...

Installation

npx baseui-cn add avatar

Usage

import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarGroup,
  AvatarGroupCount,
  AvatarImage,
} from "@/components/ui/avatar"
<Avatar size="md">
  <AvatarImage src="/photo.jpg" alt="Aria Chen" />
  <AvatarFallback>AC</AvatarFallback>
  <AvatarBadge className="bg-success" />
</Avatar>

Examples

Basic

An avatar with fallback initials.

Loading preview...

With image

Image avatars fall back to initials when the image is unavailable.

Loading preview...

Image sizes

Use xs, sm, md, and lg to keep avatars aligned with nearby controls and cards.

Loading preview...

With badge

Status badges use your theme tokens so online and away states still feel native to the app.

Loading preview...

Group

Stack avatars together and add an overflow count when you do not want to render every participant.

Loading preview...

Sizes

The core avatar supports xs, sm, md, and lg sizing for denser or roomier layouts.

Loading preview...

Image group

The grouped pattern also works with uploaded images and mixed fallbacks.

Loading preview...

API

Avatar

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg""md"Diameter of the avatar circle and font size of the fallback initials
showBadgebooleanfalseRender a presence/status badge overlay on the avatar
badgeVariant"online" | "offline" | "busy" | "away""online"Color of the presence badge (requires showBadge)
badgePosition"top-right" | "top-left" | "bottom-right" | "bottom-left""top-right"Corner placement of the badge

AvatarBadge

Use AvatarBadge directly for fine-grained control over the badge separately from Avatar.

PropTypeDefaultDescription
variant"online" | "offline" | "busy" | "away""online"Presence status color
badgePosition"top-right" | "top-left" | "bottom-right" | "bottom-left""top-right"Corner placement

AvatarGroupCount

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg""md"Diameter to match the rest of the avatar group

API Reference

See the Base UI Avatar documentation for the full API reference, including all props, data attributes, and CSS classes.