Skip to Content
Getting startedFoundationsComponentsPackagesTools

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.

xs
sm
md
lg
xl

Content

The colour follows the name, so one person is one colour everywhere; with no name, a fallback glyph.

Ada Lovelace
Grace Hopper
Katherine Johnson
Radia Perlman
no name

Status

The status dot sits outside the clipped circle, so it is never cut off.

online
away
busy
offline

Install

npx shadcn add @hipuku/avatar

Usage

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.

PropType
altstring
namestring
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 with alt if you pass one.
  • status is 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.

On this page