Components
Avatar
Avatar is a small image that stands in for a single user or item, such as a profile picture that shows at a glance who left a comment or post.
Definition
An avatar is a small image that stands in for a single user or item. A profile picture is the most common example, and in lists, comments, or chat screens it tells you at a glance who left something behind. When there's no photo, or the photo fails to load, you fill the spot with the initials from a name or a default person icon instead — that way a blank spot never shows through. The shape is usually a circle, which feels soft and holds a face naturally, so it has become the go-to marker for representing people. Depending on the situation you might use a rounded square instead, and for things like organizations or teams you can drop in a logo or symbol to set them apart from individual people.
Why does it matter?
Avatars matter because they let you recognize a person far faster than reading their name. We notice a small picture — a face or a splash of color — before we read text, so even in a long list an avatar lets you spot the person you want almost instantly. An avatar also breathes a bit of human warmth into an otherwise stiff screen, giving the feeling that real people actually use this space. In collaboration tools and social apps especially, a single small picture compresses information like who is taking part and whether they're online right now, so it becomes a tiny but dense unit that helps users grasp relationships and context quickly. That's why handling avatars well, even on their own, makes a screen feel friendlier and easier to read.
Common mistakes
- Not planning for image loading to fail. When a photo URL breaks, a broken image icon or an empty box shows up right where the face should be, and the polish you worked hard for collapses in an instant, taking the sense of trust down with it.
- Making avatars so small that the face or initials become impossible to read. When the representative image is squashed down to where you can't tell who it is, the whole point of adding an avatar disappears and it becomes decoration that just takes up space and slows down scanning.
- Dropping in images of wildly different sizes and letting the avatar get distorted. Forcing photos with mismatched aspect ratios to fill the frame stretches or squishes the face, which ends up making the person look comical and ruins the impression of a carefully chosen photo.
Practical tips
- Always prepare a fallback for when the image is missing or fails to load. Pairing a name's initials or a default icon with a per-person background color fills the gap seamlessly and makes people easy to tell apart.
- When you're listing several people, overlap the avatars slightly, and if they won't all fit, summarize the rest as a plus-N badge at the end. Even in a tight space the size of the group comes across at a glance.
- Show status like online presence with a small ring or dot around the edge of the avatar. It layers status on without covering the face, and since color alone shouldn't carry the meaning, adding a short label when needed is the safer choice.
Ask your AI
In the avatar component I'll paste below, make it fall back gracefully when the image is missing or fails to load (onError) so a broken-image icon or empty box never shows through. Cascade in this order: photo → name initials (1–2 letters) → default person icon, and derive the initials' background color by hashing the name string so each person always gets the same consistent color and stays easy to tell apart. Render photos with object-fit: cover and a square crop so aspect ratios never distort, and mask the whole thing to a circle (border-radius: 50%). Wire it to [name / image URL fields — e.g. user.name, user.avatarUrl].
Build a stacked avatar group that shows up to [max shown — e.g. 4] avatars and summarizes the rest as a "+N" circle at the end. Overlap them by 30–40% with negative margins, and step the z-index down from left to right so each avatar sits on top of the next. Give every avatar a 2px ring in the background color so the overlapping edges stay crisp, and keep the circular, square-cropped shape. Add an aria-label like "and N more" to the whole group so screen readers get the head count too.
Add a small status dot to the bottom-right corner of the avatar to show online presence. Wrap the dot in a 2px ring matching the avatar's background color so it separates from the body, and size it to only about 25–30% of the avatar's diameter so it never covers the face. Since color alone shouldn't carry the meaning, convey online / away / offline with color plus a short status label or aria-label, and wire it to [presence source — e.g. user.presence].