Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
Usage
Examples
Sizes
Use the size prop to change the size of the avatar.
Variants
Use the variant prop to change the variant of the avatar.
Shapes
Use the shape prop to change the shape of the avatar.
Fallback
If the image fails to load, the avatar will display the user’s initial. When no name is provided, a generic icon is shown instead.
Colors
Combine the colorPalette prop with some custom logic to dynamically change the color of the avatar.
Ring
Use the outline props to add a ring around the avatar.
Group
The Group component lets you display multiple avatars together. Use the stacking prop to control the order in which avatars overlap.
Badge
Show a badge on the right corner of the avatar by composing the Float and Circle components.
Persona
Here's an example of how to use the Avatar component to display a user persona.
Christian Busch
christian@park-ui.com
Next.js
Here's an example of how to compose the avatar with Next.js Image.
Closed Component
Here's how to setup the avatar for a closed component composition.
Props
Root
| Prop | Default | Type | 
|---|---|---|
| size | 'md' | 'full' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 
| variant | 'subtle' | 'solid' | 'surface' | 'subtle' | 'outline' | 
| shape | 'full' | 'full' | 'square' | 'rounded' | 
| borderless | boolean | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| ids | Partial<{ root: string; image: string; fallback: string }>The ids of the elements in the avatar. Useful for composition. | |
| onStatusChange | (details: StatusChangeDetails) => voidFunctional called when the image loading status changes. | 
Fallback
| Prop | Default | Type | 
|---|---|---|
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | 
Image
| Prop | Default | Type | 
|---|---|---|
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. |