Migration Guide for nv-avatar
In the latest version of the nv-avatar component, we've made several important changes to the properties to improve usability and consistency. Below is a guide to help you update your existing avatars from version 2 to version 3.
Deprecations#
1. prop large, medium, small, xSmall, xLarge -> size#
The size properties have been consolidated into a single size property with an enum type.
Old Usage:
<NvAvatar Large="true"></NvAvatar>
<NvAvatar Medium="true"></NvAvatar>
<NvAvatar Small="true"></NvAvatar>
<NvAvatar Xlarge="true"></NvAvatar>
<NvAvatar Xsmall="true"></NvAvatar>
New Usage:
<NvAvatar Size="NvAvatar.SizeEnum.lg"></NvAvatar>
<NvAvatar Size="NvAvatar.SizeEnum.md"></NvAvatar>
<NvAvatar Size="NvAvatar.SizeEnum.sm"></NvAvatar>
<NvAvatar Size="NvAvatar.SizeEnum.xl"></NvAvatar>
<NvAvatar Size="NvAvatar.SizeEnum.xs"></NvAvatar>
2. prop rounded, square removed#
The shape properties have been deprecated. The new architecture does not support these properties directly; instead, use CSS classes as needed.
Old Usage:
<NvAvatar Rounded="true"></NvAvatar>
<NvAvatar Square="true"></NvAvatar>
3. prop text -> initials#
The text property has been renamed to initials.
Old Usage:
<NvAvatar Text="AB"></NvAvatar>
New Usage:
<NvAvatar Initials="AB"></NvAvatar>
4. prop url -> src#
The url property has been renamed to src.
Old Usage:
<NvAvatar Url="image_url"></NvAvatar>
New Usage:
<NvAvatar Src="image_url"></NvAvatar>
Breaking Changes#
1. prop icon -> slot#
The icon property has been removed. The new architecture does not support this property, use a slot instead.
Old Usage:
<NvAvatar Icon="iconName"></NvAvatar>
New Usage:
<NvAvatar>
<IconSlot><NvIcon Name="iconName"></NvIcon></IconSlot>
</NvAvatar>
2. prop color no longer has semantic colors#
You can no longer set the color with values like primary, secondary, success, error and neutral. Instead use numeric values as a string between 0 and 4.
Old Usage:
<NvAvatar Color="primary"></NvAvatar>
<NvAvatar Color="secondary"></NvAvatar>
<NvAvatar Color="success"></NvAvatar>
<NvAvatar Color="error"></NvAvatar>
<NvAvatar Color="neutral"></NvAvatar>
New Usage:
<NvAvatar Color="0"></NvAvatar>
<NvAvatar Color="1"></NvAvatar>
<NvAvatar Color="2"></NvAvatar>
<NvAvatar Color="3"></NvAvatar>
<NvAvatar Color="4"></NvAvatar>
New Properties#
1. alt: Provides an alternative text description for the avatar image.#
New Usage:
<NvAvatar Alt="User's profile picture"></NvAvatar>