Skip to main content
Data DisplayLevel 1

Avatar

头像

WebMobileDesktopDifficulty: Easy

A small round image that stands in for a person or an entity.

01

Live Demo

Actually clickable
MMia ChenLLin XiaoWWang DachuiZZhao Min

An avatar always needs a fallback: initials → default icon.

In a real product these are photos; this is the fallback — a soft background from the initial letter.

What you just saw:The round portrait at the left of a chat list, the small circle next to a GitHub username, the avatar on every comment row.

02

What it actually is

An avatar lets users recognize who or what something is at a glance, without reading names. The fallback chain matters enormously: when the image fails to load, show the initials of the name (the surname for Chinese names), and when that fails too, show a generic person icon.

avatarprofile pictureuser pictureprofile imageinitials fallbackpresence ring
03

Anatomy · What it's made of

  1. Image图片

    Square source cropped to a circle

  2. Fallback降级

    Initials / default icon

  3. Ring描边

    Presence indicator or VIP marker

  4. Size尺寸

    xs 16 / sm 24 / md 32 / lg 40 / xl 64

04

When to Use

When it fits, and when it doesn't
Avatar usage recommendations
SituationUse it?
You need to tell different people or entities apartYes
A list contains multiple peopleYes
You need to show who is currently signed inYes
There is only one person and no confusion is possibleDepends

An avatar that fails to load and leaves a gray hole makes the page look broken — always have a fallback.

The avatar is not the tap target; the tap target should be the whole row or the name.

05

Similar Patterns

Don't mix these up
06

How to tell AI

Three levels of prompt

Add the component name and specifics

Add an avatar to every row in a list: a 28px circle that falls back to the initials of the name (the surname for Chinese names) when the image fails, and to a default person icon if that fails too. Online users get a green ring.

07

Don't just say this to AI

Bad → Better

Don't say this to AI

Add a user avatar.

Say this instead

Add avatars: a circle with object-fit: cover, an onError fallback chain of "initials (surname for Chinese names), then a default person icon", a background color hashed from the name, a white border plus a green ring for presence, and the real name as alt text.

08

Share this card

Social-ready

Turn this pattern into a 3:4 or 1:1 knowledge card and export it as PNG right in the browser. No backend needed.