Small
.avatar--sm — dense lists and chips.
User image or initials fallback — sizes sm, md, and lg.
Live
<span class="avatar avatar--md" role="img" aria-label="Grace Hopper">
<span class="avatar__initials" aria-hidden="true">GH</span>
</span>
<span class="avatar avatar--md">
<img class="avatar__img" src="/avatar.jpg" alt="Demo user" />
</span>
import { Avatar } from 'caustica-design/core'
import 'caustica-design/css'
<Avatar size="md" initials="GH" label="Grace Hopper" />
<Avatar size="md" src="/avatar.jpg" alt="Demo user" initials="DU" />
.avatar--sm — dense lists and chips.
.avatar--md — default size.
.avatar--lg — profile headers.
.avatar__img with meaningful alt; React falls back to
initials on load error.
aria-label or
React label / aria-label, with role="img".
alt on the
<img> — do not also set role="img" on the wrapper.
aria-hidden="true" when the root already has a
name.
| Class | Description |
|---|---|
.avatar |
Root pill container. |
.avatar--sm / --md / --lg |
Size modifiers. |
.avatar__img |
Cover-fit image. |
.avatar__initials |
Fallback initials layer. |
From src/core/Avatar.tsx — extends
HTMLAttributes<HTMLSpanElement> (minus children).
| Prop | Type | Default | Description |
|---|---|---|---|
size |
'sm' | 'md' | 'lg' |
'md' |
Maps to .avatar--*. |
src |
string |
— | Image URL; requires alt. |
alt |
string |
— | Required when src is set. |
initials |
string |
— | Shown without image or after load error. |
label / aria-label |
string |
— | Required accessible name for initials-only. |
className |
string |
— | Merged onto the root. |