Tac UIv1.1.2

Avatar

Displays a user image, initials, or icon in a circular frame with optional status indicator.

Import

tsx
import { Avatar } from '@tac-ui/web';

Playground

Interactively configure the Avatar props below.

JD
tsx
<Avatar size="md" initials="JD" />

Sizes

Four sizes from compact indicators to large profile displays.

User
User
User
User
tsx
<Avatar size="sm" src="/avatar.jpg" alt="User" />
<Avatar size="md" src="/avatar.jpg" alt="User" />
<Avatar size="lg" src="/avatar.jpg" alt="User" />
<Avatar size="xl" src="/avatar.jpg" alt="User" />

Initials

Text initials are shown when no image is provided.

JD
AB
CK
MR
tsx
<Avatar size="sm" initials="JD" />
<Avatar size="md" initials="AB" />
<Avatar size="lg" initials="CK" />
<Avatar size="xl" initials="MR" />

Icon Fallback

An icon is displayed when neither image nor initials are available.

tsx
<Avatar size="sm" icon={<User />} />
<Avatar size="md" icon={<User />} />
<Avatar size="lg" icon={<User />} />
<Avatar size="xl" icon={<User />} />

Status Indicator

A status dot on the bottom-right corner indicates online presence.

JDOnline
UserOnline
ABOnline
UserOnline
tsx
<Avatar size="sm" initials="JD" showStatus />
<Avatar size="md" src="/avatar.jpg" alt="User" showStatus />
<Avatar size="lg" initials="AB" showStatus />
<Avatar size="xl" src="/avatar.jpg" alt="User" showStatus />

Status with Content

Replace the status dot with custom icons for richer status indicators.

User
AB
User
tsx
<Avatar size="md" src="/avatar.jpg" statusContent={<Camera />} statusColor="var(--primary)" />
<Avatar size="lg" initials="AB" statusContent={<Shield />} statusColor="var(--warning)" />
<Avatar size="xl" src="/avatar.jpg" statusContent={<Star />} statusColor="var(--error)" />

Status Colors

Change the status dot color to represent different states.

ONOnline
AWOnline
OFOnline
IDOnline
tsx
<Avatar size="lg" initials="ON" showStatus />
<Avatar size="lg" initials="AW" showStatus statusColor="var(--warning)" />
<Avatar size="lg" initials="OF" showStatus statusColor="var(--error)" />
<Avatar size="lg" initials="ID" showStatus statusColor="var(--muted-foreground)" />

Animated

Enable hover animation with a subtle lift and scale effect.

JD
UserOnline
AB
tsx
<Avatar size="md" initials="JD" animated />
<Avatar size="lg" src="/avatar.jpg" alt="User" animated showStatus />
<Avatar size="xl" initials="AB" animated />

API Reference

PropTypeDefaultDescription
size"sm" | "md" | "lg" | "xl""md"Size of the avatar.
srcstring-URL of the image to display. Falls back to initials or icon on error.
altstring-Accessible alt text for the image.
initialsstring-Text initials shown when no image is available.
iconReact.ReactNode-Icon node shown when no image or initials are available.
showStatusbooleanfalseRenders a status dot in the bottom-right corner.
statusContentReact.ReactNode-Custom content inside the status badge. Automatically shows the badge when provided.
statusColorstring"var(--success)"Background color for the status badge.
animatedbooleanfalseEnables a subtle hover animation (lift and scale).
classNamestring-Additional CSS class names.