Skip to content

React Avatar Component

A glass React avatar component that shows an image, falls back to gradient initials, and can show an online status dot.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/avatar.json

Design team

Everyone is offline.

Sizes, status and groups

Files to copy

3 folders · 2 files · 4 packages
From theme/src/
  • components/avatar/
  • lib/{cn.ts, initials.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/avatar.jsonRegistry item: avatar. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/spinner/
  • components/toast/
  • hooks/{use-direction.ts, use-media-query.ts}
  • motion/tokens.ts
  • lib/state-light.tsx
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toast.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Clickable and labeled

An avatar is not interactive: wrap it in a button with a name, and label a group so people know who it shows.

Props

PropTypeDefaultDescription
name (required)stringNoneFull name: used for alt text and the initials fallback.
srcstringNoneImage URL. While it loads (or if it fails) the initials show instead.
size"sm" | "md" | "lg""md"Sets the diameter: "sm" 32px, "md" 40px, "lg" 56px.
status"online" | "away" | "offline"NonePresence dot at the bottom-right corner: online, away or offline (a hollow ring). Hidden when omitted.
classNamestringNoneAdds extra classes to the outer element.

Keyboard

KeysAction
TabNot focusable: an Avatar is not interactive. Wrap it in a button or link when it should be clickable.

Accessibility

  • An image avatar uses the person's name as its alt text. The initials fallback is role="img" with the full name as its label.
  • The presence dot is its own labeled image (online, away, offline). Offline is a hollow ring, so states differ by shape, not only by color.
  • In AvatarGroup, pass an aria-label that says who the people are; each avatar keeps its own name.
  • Forced colors use system colors with an edge, so the status dot stays visible.

When to use Avatar

  • Use Avatar with an initials fallback beside each author in a comment thread or activity feed, where a profile picture gives people a quick visual anchor and initials cover users who never uploaded one.
  • Use the status prop for an avatar with status in a team directory or chat sidebar that shows who is online, away or offline, with the hollow ring marking offline so color is not the only cue.
  • Use AvatarGroup for a stack of project members on a card header, labeled with an aria-label that says who the people are, such as Project members.
  • Skip it when the picture itself must be clicked or must act as a control. Avatar takes no focus, so wrap it in a Button or a link, or use a Badge for non-person labels.
  • Pair it with Tooltip to reveal a full name on hover, DataTable for a user column with a picture, and Badge for a role label placed under the name.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .