Migration Guide for nv-alert
In the latest version of the nv-alert 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 alerts from version 2 to version 3.
Deprecations#
1. prop color#
The color property has been deprecated in favor of feedback. This change aligns the property name more closely with its function, which is to indicate the nature of the alert (e.g., information, warning, success, error).
Old Usage:
<NvAlert Color="NvAlert.ColorEnum.primary"></NvAlert>
New Usage:
<NvAlert Feedback="NvAlert.FeedbackEnum.information"></NvAlert>
Breaking Changes#
1. prop permanent -> hidden#
The permanent property has been replaced by hidden. In v2, permanent was used to make the alert always visible. Now, hidden controls the visibility inversely; the alert is visible by default, and setting hidden to true hides it.
Old Usage:
<NvAlert Permanent="true"></NvAlert>
New Usage:
<NvAlert Hidden="true"></NvAlert>
2. prop close -> dismissible#
The close property has been renamed to dismissible. This new name better describes the property's functionality, which allows the alert to be closed by the user.
Old Usage:
<NvAlert Close="true"></NvAlert>
New Usage:
<NvAlert Dismissible="true"></NvAlert>
3. prop visible -> hidden (with added animation)#
The visible property has been replaced with hidden and now always includes animation effects when the alert is shown or hidden.
Old Usage:
<NvAlert Visible="true"></NvAlert>
New Usage:
<NvAlert Hidden="true"></NvAlert> // Remove or set to false to show the alert
4. event close -> closeClicked#
The close event has been renamed to closeClicked. This is more descriptive of the event's purpose, as the hiding of the alert could be intercepted by the preventAutoClose prop.
Old Usage:
<NvAlert Close="handleClose"></NvAlert>
New Usage:
<NvAlert CloseClickedEvent="handleClose"></NvAlert>
New Properties#
1. heading: Provides a prop to pass text to the heading of the alert, instead of passing the markup directly.#
New Usage:
<NvAlert Heading="Styles are now automatically applied to the alert heading."></NvAlert>
2. message: Provides a prop to pass text to the message of the alert.#
New Usage:
<NvAlert Message="This is the body of the alert."></NvAlert>
3. 'preventAutoClose': Provides a prop to prevent the alert from hiding automatically when the close button is clicked. This is useful for externally controlled component behavior.#
New Usage:
<NvAlert Dismissible="true" PreventAutoClose="true"></NvAlert>
Visual Changes in 3.x#
1. Default icons of information and neutral#
The default icons of information and neutral now match nv-notification and nv-statusindicator: information uses info-circle and neutral uses help. An unknown feedback uses info-circle.
This reverts the icon change of 3.43.0 (#950). If you set icon to keep info-circle or help, you can remove it.
Old Usage:
<NvAlert Feedback="NvAlert.FeedbackEnum.information" Icon="NvIcon.NameEnum.infocircle"></NvAlert>
<NvAlert Feedback="NvAlert.FeedbackEnum.neutral" Icon="NvIcon.NameEnum.help"></NvAlert>
New Usage:
<NvAlert Feedback="NvAlert.FeedbackEnum.information"></NvAlert>
<NvAlert Feedback="NvAlert.FeedbackEnum.neutral"></NvAlert>