Tuimorphic

Avatar

Display user images, initials, or icons for visual identification.

Import

import { Avatar } from 'tuimorphic';

Basic Usage

User avatar
<Avatar src="/user.jpg" alt="John Doe" />

Props

PropTypeDefaultDescription
srcstring-Image source URL
altstring''Alt text for the image
initialsstring-Initials to display when no image is provided or image fails to load
size'small' | 'medium' | 'large''medium'Size variant
hrefstring-Optional link URL - renders as anchor when provided
targetstring-Link target (e.g., "_blank")
classNamestring-Additional CSS class names

Variants

With Image

User 1User 2User 3
<Avatar src="/user.jpg" alt="John Doe" />

With Initials Fallback

JDABXY
<Avatar initials="JD" />
<Avatar src="/user.jpg" alt="Profile" href="/profile" />
<Avatar src="/user.jpg" href="/profile" target="_blank" />

Size Variants

SMMDLG
<Avatar initials="SM" size="small" />
<Avatar initials="MD" size="medium" />
<Avatar initials="LG" size="large" />

Avatar Group

AB
CD
EF
GH
+3
<div style={{ display: 'flex', gap: '8px' }}>
  <Avatar initials="JD" />
  <Avatar initials="AS" />
  <Avatar initials="MK" />
</div>

Image with Fallback

When the image fails to load, initials are displayed:

Fallback demo(Image fails, shows initials fallback)
<Avatar
  src="/nonexistent.jpg"
  alt="Jane Smith"
  initials="JS"
/>

On this page