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
solid
soft
Accent
Gray
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.
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"
.
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.