Avatar

stable 1.1 kB
<hk-avatar>

Image, initials or icon, with a stack mode that collapses the overflow into a +N. Initials are derived from the name, so a missing image is never a broken image.

#user#image

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
namestring''Used for initials and for the accessible name.
srcstring''Image URL. Falls back to initials on error.
size'sm' | 'md' | 'lg''md'Diameter.
onlineboolean | nullnullShows a presence dot when set.
maxnumber3On a stack, how many to show before the +N.

Keyboard

  • Enter Expands a collapsed stack

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-avatar-size2.75remDiameter.
--hk-avatar-ring#ffffffRing between stacked avatars.
--hk-avatar-bglinear-gradient(135deg, #dc2626, #7f1d1d)Initials background.

Accessibility

  • A broken image falls back to initials rather than an alt-text box.
  • Presence is announced as text, not conveyed by the green dot alone.
  • The +N overflow is a button that expands the stack, not decoration.

More in Data