Import
Usage
Anatomy
Avatar- Root container with size contextAvatar.Image- Profile image with loading statesAvatar.Fallback- Fallback content (typically initials)Avatar.Badge- Status indicator badgeAvatar.Group- Container for multiple avatarsAvatar.GroupCount- Count indicator for overflow avatars
Props
Avatar
Controls the avatar size:
xs- Size 5 (20px)sm- Size 6 (24px)md- Size 8 (32px)lg- Size 10 (40px)xl- Size 11 (44px)
Additional CSS classes to apply.
Avatar.Image
The image source URL.
Alternative text for the image.
Additional CSS classes.
Avatar.Fallback
Fallback content, typically user initials.
Additional CSS classes.
Avatar.Badge
Status variant for the badge.
Additional CSS classes.
Avatar.Group
Maximum number of avatars to show before using count indicator.
Additional CSS classes.
Avatar.GroupCount
Number of overflow avatars.
Additional CSS classes.
Examples
With image
Fallback only
When no image is provided or loading fails:With status badge
Different sizes
Avatar group
Display multiple avatars in a stacked layout:Clickable avatars
Data Attributes
[data-size]- Reflects the current size[data-slot]- Component identifier (avatar, avatar-image, avatar-fallback)[data-state]- Image loading state (loading, loaded, error)
Accessibility
- Avatar.Image requires
alttext for screen readers - Fallback content is announced when image fails
- Sufficient color contrast in fallback backgrounds
- Border ring provides visual separation
- Interactive avatars should be wrapped in button/link elements
Base UI Integration
Avatar uses Base UI’s Avatar primitive for:- Automatic image loading states
- Fallback content when image fails or is loading
- Proper ARIA attributes
- State management for image lifecycle