structyl

Avatar API

View component

The full prop reference for the Avatar component. An image element with a fallback for representing the user.

Import

tsx
import { Avatar } from '@structyl/styled';

Props

Avatar.Root

Container for the avatar with optional status indicator

PropTypeDefault
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#boolean

If true, renders as child component instead of span

className#string

CSS class name for custom styling

Avatar.Image

Image element that displays when loaded; controlled by loading status

PropTypeDefault
src#string

Image source URL

onLoadingStatusChange#(status: 'idle' | 'loading' | 'loaded' | 'error') => void

Callback fired when image loading status changes

asChild#boolean

If true, renders as child component instead of img

className#string

CSS 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

PropTypeDefault
delayMs#number

Delay in milliseconds before the fallback is shown to avoid flicker on fast image loads

asChild#boolean

If true, renders as child component instead of span

className#string

CSS 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

PropTypeDefault
max#number

Maximum 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#string

CSS class name for custom styling

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library