Basic Usage
With Fallback Content
Component Structure
The avatar component consists of three parts:Avatar Root
The main container for the avatar:Avatar Image
Displays the user’s profile image:Avatar Fallback
Shown when the image fails to load:Props Reference
Root Props
The image source URL (high-level API)
Additional CSS classes for styling
Image Props
The image source URL
Callback when loading status changes. Receives the status string as parameter.
Fallback Props
How long to wait before showing the fallback. Specified in milliseconds.
Styling
The avatar uses these default classes fromreflex_ui/components/base/avatar.py:14-16:
- Root:
shrink-0 inline-flex size-6 items-center justify-center overflow-hidden rounded-full bg-secondary-1 align-middle text-base font-medium text-secondary-12 select-none - Image:
size-full object-cover shrink-0 - Fallback:
flex size-full items-center justify-center text-sm animate-pulse bg-secondary-6
Implementation Details
From source code atreflex_ui/components/base/avatar.py:87-111:
- High-level API automatically creates root, image, and fallback components
- Image props are passed to the image component
- Fallback props control the fallback behavior
- Renders with proper accessibility attributes via
data-slotproperties