Angular playground

Nova v3.37.0

Preview

Angular

nv-avatar migration

Moving from the size flags, text and url to size, initials and src.

← nv-avatar

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:

html<nv-avatar large></nv-avatar>
<nv-avatar medium></nv-avatar>
<nv-avatar small></nv-avatar>
<nv-avatar xLarge></nv-avatar>
<nv-avatar xSmall></nv-avatar>

New Usage:

html<nv-avatar size="lg"></nv-avatar>
<nv-avatar size="md"></nv-avatar>
<nv-avatar size="sm"></nv-avatar>
<nv-avatar size="xl"></nv-avatar>
<nv-avatar size="xs"></nv-avatar>

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:

html<nv-avatar rounded></nv-avatar>
<nv-avatar square></nv-avatar>

3. prop text -> initials

The text property has been renamed to initials.

Old Usage:

html<nv-avatar text="AB"></nv-avatar>

New Usage:

html<nv-avatar initials="AB"></nv-avatar>

4. prop url -> src

The url property has been renamed to src.

Old Usage:

html<nv-avatar url="image_url"></nv-avatar>

New Usage:

html<nv-avatar src="image_url"></nv-avatar>

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:

html<nv-avatar icon="iconName"></nv-avatar>

New Usage:

html<nv-avatar>
  <nv-icon slot="icon" name="iconName"></nv-icon>
</nv-avatar>

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:

html<nv-avatar color="primary"></nv-avatar>
<nv-avatar color="secondary"></nv-avatar>
<nv-avatar color="success"></nv-avatar>
<nv-avatar color="error"></nv-avatar>
<nv-avatar color="neutral"></nv-avatar>

New Usage:

html<nv-avatar color="0"></nv-avatar>
<nv-avatar color="1"></nv-avatar>
<nv-avatar color="2"></nv-avatar>
<nv-avatar color="3"></nv-avatar>
<nv-avatar color="4"></nv-avatar>

New Properties

1. alt: Provides an alternative text description for the avatar image.

New Usage:

html<nv-avatar alt="User's profile picture"></nv-avatar>