Docs
πŸ—οΈ ⏐ Components
Elements
Avatar

Avatar

The "Avatar" component is a versatile UI element designed to display visual identifiers for users, such as profile pictures or initials. It's widely used across applications to personalize user experiences, especially in sections related to user profiles, comments, or team pages.

Quick Start

To start using the Avatar component, import it from the reablocks library and provide the name prop.

TR

Examples

Basic Usage

Displaying User Initials

The Avatar component can automatically generate and display initials based on the user's name. For names comprising multiple words, it uses the first letter of each word. For single-word names, only the first letter is displayed:

Displaying Profile Pictures

When a URL to a user's profile picture is available, the Avatar component can display the image within a circular frame, adhering to the common design pattern for user avatars:

Theme Customization

The Avatar component comes with a default theme that can be customized. The base theme includes styles for center alignment, background cover, and text styling, with an option to make the avatar rounded:

  • root{}(2 keys)
      Show all

Learn more about how to customize in the Theme documentation.

API

Customize the Avatar component through the following properties:

PropDescriptionDefault
nameThe name of the person.
string
srcThe URL of the avatar image.
string
sizeThe size of the avatar.
number
24
variantStyle variant for the avatar.
"filled" | "outline"
filled
roundedWhether the avatar is rounded.
boolean
true
colorColor override for the avatar.
string
colorOptionsCustom color options for the color generator.
{ saturation: number; lightness: number; alpha: number; }
themeTheme for the Avatar.
AvatarTheme

Design and Usability Tips

  • Optimal Resolution: For user avatars, ensure that images are displayed at an optimal resolution to maintain visual clarity without unnecessarily burdening the page load times. Consider implementing a standard size for avatars across your application to create a consistent and professional appearance.