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.jsonDesign team
Everyone is offline.
Sizes, status and groups
import { Avatar, AvatarGroup } from "@/components/sheenui/avatar/avatar";
// Package build (after the first npm release, or a packed tarball): import { Avatar, AvatarGroup } from "@sheenui/theme";
export function Example() {
return (
<>
<Avatar name="Ada Lovelace" size="lg" status="online" />
<Avatar name="Asha Verma" status="away" />
<AvatarGroup>
<Avatar name="Ravi Kumar" size="sm" />
<Avatar name="Meera Iyer" size="sm" />
<Avatar name="John Doe" size="sm" />
</AvatarGroup>
</>
);
}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.tslib/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.
import { Avatar, AvatarGroup } from "@/components/sheenui/avatar/avatar";
import { useToast } from "@/components/sheenui/toast/toast";
// Package build (after the first npm release, or a packed tarball): import { Avatar, AvatarGroup, useToast } from "@sheenui/theme";
// This example also uses toast: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toast.json
export function Example() {
const toast = useToast();
return (
<>
<button
type="button"
aria-label="AL, open Ada Lovelace's profile"
onClick={() => toast.success("Opening profile")}
className="sheen-hit rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sheen-focus"
>
<Avatar name="Ada Lovelace" status="online" />
</button>
<Avatar name="Grace Hopper" size="lg" status="away" />
<AvatarGroup aria-label="Design team: Ravi, Meera and John">
<Avatar name="Ravi Kumar" size="sm" />
<Avatar name="Meera Iyer" size="sm" />
<Avatar name="John Doe" size="sm" />
</AvatarGroup>
</>
);
}Props
Keyboard
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
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .