Avatar API
View componentThe full prop reference for the Avatar component. An image element with a fallback for representing the user.
Import
import { Avatar } from '@structyl/styled';Props
Avatar.Root
Container for the avatar with optional status indicator
| Prop | Type | Default |
|---|---|---|
| size# | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'Size variant of the avatar | 'md' |
| status# | 'online' | 'offline' | 'busy' | 'away'Optional status indicator dot to show online/offline/busy/away state | — |
| asChild# | booleanIf true, renders as child component instead of span | — |
| className# | stringCSS class name for custom styling | — |
Avatar.Image
Image element that displays when loaded; controlled by loading status
| Prop | Type | Default |
|---|---|---|
| src# | stringImage source URL | — |
| onLoadingStatusChange# | (status: 'idle' | 'loading' | 'loaded' | 'error') => voidCallback fired when image loading status changes | — |
| asChild# | booleanIf true, renders as child component instead of img | — |
| className# | stringCSS class name for custom styling (inherits aspect-square h-full w-full object-cover) | — |
Avatar.Fallback
Fallback content shown while image loads or if it fails to load
| Prop | Type | Default |
|---|---|---|
| delayMs# | numberDelay in milliseconds before the fallback is shown to avoid flicker on fast image loads | — |
| asChild# | booleanIf true, renders as child component instead of span | — |
| className# | stringCSS class name for custom styling (inherits bg-muted text-muted-foreground flex items-center justify-center rounded-full font-medium uppercase) | — |
Avatar.Group
Container for displaying multiple avatars with overflow count
| Prop | Type | Default |
|---|---|---|
| max# | numberMaximum number of avatars to show before displaying overflow count | — |
| size# | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'Size variant applied to all child avatars and overflow indicator | 'md' |
| className# | stringCSS class name for custom styling | — |
Source code
If you didn't find what you need here, read the component implementation .