Avatar #
va-avatar
component is typically used for user profile pictures. The component helps you display it in different sizes consistently throughout your web application.
Examples #
Default #
By default va-avatar
is displayed as a circle container.
With image #
The src
prop is used to add custom image to a component.


Fallback #
You can set fallback image.
Integrate with Gravatar #
You can easily use Gravatar with VaAvatar
component.
With icon #
The icon
prop is used to display icon inside an avatar.
Different colors #
The color
prop is used to set the color of the component and text-color
for its textual content.
Different sizes #
The size
prop allows you to specify custom size for an avatar. By default, font size will be scaled depending on the value of the size
prop. But you can use the font-size
prop to force text size you need.
Square #
The square
prop is used to change components form from round to square.

Loading #
The loading
prop sets a loading state for the component via spinner icon.
With badge #
You may combine va-avatar
with va-badge
, for example, to output amount of the new notifications.

Grouped #
You can use va-avatar-group
component to group avatars.



API #
Props #
Name | Description | Types | Default |
---|---|---|---|
loading | Indicates that something is loading (spinner icon). |
|
|
size | Specify size for component. |
|
|
sizes-config |
|
| |
font-sizes-config |
|
| |
preset | Named preset combination of component props. |
| - |
color | Color of the component (theme string or |
|
|
text-color | Text color (theme string or HEX string). |
| - |
square | Removes rounded corners. |
|
|
font-size | The font-size of text inside avatar |
|
|
fallback-src | Shows an alternative image if original image failed to load or src doesnโt specified. |
| - |
fallback-text | Shows an alternative text if image failed to load or src doesnโt specified. |
| - |
fallback-icon | Shows an icon if image failed to load or src doesnโt specified. |
| - |
fallback-render | Allows to use render function to render custom contents if image failed to load or src doesnโt specified |
| - |
src | URL to the image (will be placed inside |
|
|
icon | The icon to be displayed inside a container |
|
|
alt | Specifies an alternate text for an avatar image (not icon) |
|
|
Events #
Name | Description |
---|---|
error | Triggers when failed to load an image |
Slots #
Name | Description |
---|---|
default | Use this slot to replace default content to be displayed inside the component |
Css Variables #
Name | Default Value |
---|---|
--va-avatar-display | inline-flex |
--va-avatar-align-items | center |
--va-avatar-justify-content | center |
--va-avatar-text-align | center |
--va-avatar-vertical-align | middle |
--va-avatar-position | relative |
--va-avatar-line-height | normal |
--va-avatar-border-radius | 50% |