cnippet/ui
  1. ui
  2. media
  3. avatar

media

Avatar

An image element with a fallback for representing the user. Built with Base UI and Tailwind CSS. Copy-paste ready.

API Reference

Installation

Usage

Anatomy

Good to know

  • The image only appears after it has loaded. Until then, or if it fails, the fallback shows.
  • Add delay (in ms) to AvatarFallback to avoid a flash of initials when the image loads quickly.
  • Set the size on Avatar with className, e.g. size-10. The image and fallback fill it.
  • Always give AvatarImage an alt, or alt="" if a name is shown next to it.

API Reference

Avatar

Root container that manages image loading state. Built on Base UI's Avatar.Root.

AvatarImage

The image element. Automatically triggers the fallback when the image fails to load.

AvatarFallback

Rendered when the image is absent or fails to load. Typically contains initials or an icon.

Examples

With Fallback

Shows the AvatarFallback with initials when no image URL is provided or the image fails to load.

Different Sizes

Renders avatars at multiple sizes to show how the component scales across layout and density contexts.

Different Radius

Demonstrates square, rounded, and fully circular border radius variants for adapting the avatar to different design styles.

Avatar Group

Stacks multiple avatars with overlapping offsets to represent a collection of users in a compact row.

Group With Count

Adds a numbered overflow indicator (+N) to an avatar group when the total count exceeds the visible limit.

With Details and Badge

Pairs the avatar with a name and email label alongside a status badge for user profile list rows.

Social Proof

Shows a row of overlapping avatars beside a short text label for social proof patterns like "Trusted by 200+ teams".

Social Proof Compact

A tighter social proof strip using initials-only fallback avatars for a minimal footprint below a CTA.

With Hover Effect

Avatars in a group spread apart on hover to reveal individual images that would otherwise be obscured by overlap.

With Tooltips

Combines the hover spread effect with a Tooltip showing each user's name when the avatar is focused or hovered.

In Empty State

An empty state panel centered around an avatar placeholder, useful for "no members yet" or "invite your team" views.

With Loading State

Cycles the avatar through image-loading and fallback states to illustrate async image behavior and transitions.

With Custom Badge

Adds a custom status or role badge positioned at the bottom-right corner of the avatar.

With Ring Animation

A pulsing ring animates around the avatar to draw attention, useful for active or live streaming indicators.

With Dropdown Menu

Opens a Menu when the avatar is clicked, useful for profile quick-actions or account switchers.

Presence Grid

A grid of team member avatars each with a color-coded status dot (green for Online, red for Busy, yellow for Away, grey for Offline) positioned at the bottom-right.

Comment Thread

A vertical list of pull-request style comments — each row shows a small avatar, the author name, a relative timestamp, the comment body, and a like button with count.

Assignee Picker

A toggleable list of candidates where clicking a row selects or deselects that person as an assignee. Selected rows show a check mark and a tinted background.

Contributor Leaderboard

A ranked list of contributors with medal emoji for the top three, followed by their avatar, full name, and a commit count with a git icon.

Profile Card

A centered profile layout with a large avatar, name, username, bio, location, website link, a stats row (Repos / Followers / Following), and Follow + Message action buttons.