Notifications
Attention-grabbing and non-dismissable component that allows for extended, richly formatted body content.
Notifications are intended to be displayed within the document flow, not floating or user-dismissable like Snackbar. They can be statically visible, or transitioned in and out of view.
Basic Notification
Notifications must include an icon
. Review the docs on including icons in your project. Any nodes can be supplied for the message content
Note: It is recommended to include the iconLabel
prop with a short label for clarity, ex: iconLabel="Error"
, unless this would be repetitive of the Notification content.
Notification Types
Due to the intentful nature of Notifications, this component uses the type
property to provide a pre-determined meaningful color
, ex: green for the "success" type. Contrary to other components using a color prop which references theme palette colors such as "primary", the Notification is not tied to palette colors, with the exception of the error
type.
You may update the colors used via the theme overrides and using the key of UnifiNotification
, such as the following:
Animation and Visibility
A Notification's visibility can be programmatically controlled, and includes transition animation.
To hide a Notification, set enableTransition
and employ state management to toggle the visible
property.
The demo shows how to use createRef()
to shift focus to the Notification upon it being made visible so that the contents are read out for assistive technology.
Note for use with forms validation: An additional recommendation if using to support form validation messages is to include a skip link within the Notification to the first form field with an error. The skip link may be visible or hidden with <Typography variant="srOnly">
.