NOCTA UI

Avatar

A versatile avatar component for displaying user profile images, initials, and status indicators with dark mode support

Installation

Install the Avatar component using the nocta-ui CLI:

npx nocta-ui add avatar

Then import the component:

import { Avatar } from '@/components/ui/avatar';

Examples

Default Avatar

John Doe
JD

Sizes

Six size options are available: xs, sm, md, lg, xl, and 2xl. The default size is md.

John Doe
John Doe
John Doe
John Doe
John Doe
John Doe

Variants

The Avatar component supports two shape variants: circle (default) and square.

John Doe
John Doe
JD
JD

Status Indicators

Add status indicators to show user presence: online, offline, away, or busy.

John Doe
Jane Smith
Mike Johnson
AB

Fallback Handling

The Avatar component gracefully handles image loading failures with multiple fallback options.

John Doe
John Doe
SC
AB

Avatar Groups

Stack multiple avatars to show groups or teams.

John Doe
Jane Smith
Mike Johnson
AB
+5

API Reference

PropTypeDefaultDescription
srcstring-The image source URL
altstring''Alt text for the image
fallbackstring-Text to generate initials from, or custom initials
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'The size of the avatar
variant'circle' | 'square''circle'The shape variant
status'online' | 'offline' | 'away' | 'busy' | nullnullStatus indicator
classNamestring''Additional CSS classes to apply

The Avatar component also accepts all standard HTML div element props through the ...props spread operator.