Avatar
The Avatar component is used to represent a user, and display their profile pictures or fallback texts such as initials.
Basic Example
To create an avatar component with an image, pass the image URL as the src prop.
To display a text such as initials, set the fallback prop without passing the src prop.
Styling
Size
The size prop controls the size and spacing of the avatar. The acceptable size is from "1" to "9", with "3" being the default.
ExpandCollapse
Variant
The variant prop controls the visual style of the avatar fallback text. The variant can be "solid" or "soft". The default is "soft".
Color Scheme
The color_scheme prop sets a specific color to the fallback text, ignoring the global theme.
High Contrast
The high_contrast prop increases color contrast of the fallback text with the background.
Radius
The radius prop sets specific radius value, ignoring the global theme. It can take values "none" | "small" | "medium" | "large" | "full".
ExpandCollapse
Fallback
The fallback prop indicates the rendered text when the src cannot be loaded.
Final Example
As part of a user profile page, the Avatar component is used to display the user's profile picture, with the fallback text showing the user's initials. Text components displays the user's full name and username handle and a Button component shows the edit profile button.
Reflex User
@reflexuser
API Reference
rx.avatar
An image element with a fallback for representing the user.
variantsizecolor_schemehigh_contrastradiusProps
| Prop | Type | Description |
|---|---|---|
variant | "solid""soft" | The variant of the avatar. |
size | "1""2""3""4""5""6""7""8""9" | The size of the avatar: "1" - "9". |
color_scheme | "tomato""red""ruby""crimson""pink""plum""purple""violet""iris""indigo""blue""cyan""teal""jade""green""grass""brown""orange""sky""mint""lime""yellow""amber""gold""bronze""gray" | Color theme of the avatar. |
high_contrast | bool | Whether to render the avatar with higher contrast color against background. |
radius | "none""small""medium""large""full" | Override theme radius for avatar: "none" | "small" | "medium" | "large" | "full". |
src | str | The src of the avatar image. |
fallback | str | The rendered fallback text. |