Avatar
A person: photo or grey initials.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/avatar.jsonSizes
DPDPDPDP
Photo and fallback
SSA
AvatarStack
When to use
- Show who a row, card or request is about: Atasan, approval rows, team lists.
- The signed-in user in the top bar (size 44).
- A small group of people: "Bawahan langsung · 9 orang" (AvatarStack).
When not to use
- A department or module → an icon tile, not an avatar.
- A company → the company pill in the top bar.
- A whole team with names and roles → PersonCard grid.
Do and don't
Pass the full namename is the alt text and the source of the initials ("Dimas Pratama" → DP).
A colour per personRandom pastel fallbacks look like status colours. Keep every fallback grey.
Installation
Add Avatar with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.
API
import { Avatar, AvatarStack } from "@/components/ui/avatar"| Prop | Type | Default | Description |
|---|---|---|---|
name | string | – | Required. Alt text + initials. |
src | string | – | Photo URL. Falls back to initials while loading or on error. |
size | 24 | 32 | 40 | 44 | 56 | 96 | 40 | Closed set. |
decorative | boolean | false | The name is written next to it (rows, cards, menus): hidden from screen readers, so the name is not read twice. Off when the avatar is the only label (AvatarStack). |
AvatarStack people | { name: string; src?: string }[] | – | Shows the first max, then +N. |
AvatarStack max · size | number · AvatarSize | 5 · 32 |