Skip to content

BaseAvatar

A circular avatar that derives initials from a full name string. Automatically assigns a consistent background color based on name hash — same name always gets the same color.

Basic Usage

Demo
AJ
BS
CW
DB
EM

Custom Size

Custom Size
AJ
AJ
AJ

Props

Props
PropTypeDefaultDescription
namestring | null'User'Full name string. Derives initials (up to 2 chars). Strips common prefixes like Dr., Nurse, CFO.
sizestring'w-7 h-7'Tailwind width/height classes for the avatar circle.
textClassstring'text-xs font-bold'Tailwind text classes applied to the initials text.

Notes

  • Color is deterministic: the same name always produces the same background color.
  • Strips "Dr.", "Nurse", "CFO", and "Supervisor" prefixes before computing initials.
  • Null or empty name renders "US" (from the "User" fallback).

Built with VitePress