PU
U1
U2
U3Search for components by name, description, category or tags
An accessible avatar component with support for images, fallbacks, groups, and multiple sizes.
PU
U1
U2
U3Install the component directly into your project using the Pittaya CLI.
npx pittaya@latest add avatar
Use the Avatar component to represent users or entities visually in your application. It's ideal for profile pictures, user lists, comment sections, and team member displays.
The component automatically handles image loading failures by displaying a fallback, ensuring a consistent user experience even when images fail to load.
The Avatar component is built on top of Radix UI's Avatar primitive, ensuring robust accessibility features:
alt attributes for images to assist screen reader users.The Avatar component supports four size variants: sm, md, lg, and xl. Choose the appropriate size based on your layout and use case.
Use AvatarGroup to display multiple avatars in an overlapping stack. It automatically handles overflow by showing a count badge for additional members beyond the max limit.
Customize the appearance using className props on Avatar, AvatarImage, or AvatarFallback. You can modify borders, background colors, border radius, and more.
Combine variants and sizes to meet your needs.
A simple avatar with an image and fallback text. The fallback is only shown if the image fails to load.
Avatars support four size variants: sm (32px), md (40px), lg (48px), and xl (64px).
Avatars can display fallback content when no image is provided or when the image fails to load. You can customize the fallback styling.
Display multiple avatars in an overlapping group. Use the max prop to limit visible avatars and show a count for the rest.
AvatarGroup supports the same size variants as Avatar, applying the size to all children automatically.
Add status indicators (online, away, offline) by positioning a small badge using absolute positioning.
TSX interface that combines variants and default attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Controls the size of the avatar. Small (32px), Medium (40px), Large (48px), Extra Large (64px). |
className | string | — | Additional CSS classes to apply to the avatar root element. |
src | string | — | The image source URL to display in the avatar. |
alt | string | — | Alternative text for the image, important for accessibility. |
onLoadingStatusChange | (status: 'loading' | 'loaded' | 'error') => void | — | Callback fired when the image loading status changes. |
max | number | 3 | Maximum number of avatars to display before showing a count badge. |
count | number | — | The number to display in the count badge. |