Avatar
Initials from a name, a colour derived from it, and an optional status dot.
Examples
Playground
Size
Five sizes, 24 to 64px. The initials are centred on the circle at every size.
Content
The colour follows the name, so one person is one colour everywhere; with no name, a fallback glyph.
Status
The status dot sits outside the clipped circle, so it is never cut off.
Install
npx shadcn add @hipuku/avatarUsage
import { Avatar } from '@/components/haus/components/Avatar'
<Avatar name="Ada Lovelace" status="online" />API
Avatar also takes its element's own attributes and forwards its ref. className lands on the root.
| Prop | Type |
|---|---|
alt | string |
name | string |
size | "sm" | "md" | "lg" | "xs" | "xl" |
status | "online" | "away" | "busy" | "offline" |
Sizes
xs, sm, md, lg and xl. md is the default. xs and xl go beyond the shared scale
because an avatar is a picture, not a control: a very small one is useful in a dense table.
Colour
The colour comes from name, so the same person is the same colour everywhere with nothing to
store. With no name, a person glyph is shown instead of initials.
The colour is not an identity: there are five, so names often share one. The initials and the accessible name are what tell people apart.
Accessibility
- Announced as one image, labelled with
name, or withaltif you pass one. statusis added to that label as a word, so the dot is never colour alone.- Not interactive. Wrap it in a link or button if it should do something.