2.21.0
Notifications float in front of page content and provide information about page-level or out-of-view events. There are four types: error, warning, success, or informational.
That combination of options is invalid.
Name
|
Required
|
Description
|
---|---|---|
Message |
Yes |
Includes the core, most important notification content. |
Type |
Yes |
Affects the color and icon associated with the notification. Choose from error, warning, success or informational. |
Title |
No |
Briefly summarizes notification content. |
List |
No |
Helps structure content below a message element. |
Custom Action |
No |
Offers a follow-up action via secondary Button. |
Dismiss Action |
No |
Enables the user to remove the notification from view. |
Use for page-level errors and malfunctions, such as a file import failure or insufficient permissions to view content, or for errors that occur off of the page, such as failure to generate a report that was being created in the background.
We‘re sorry, the file you are importing timed out. Please try your import again. If your import continues to time out, please email [email protected].
We‘re sorry, the file you are importing timed out. Please try your import again. If your import continues to time out, please email [email protected].
We‘re sorry, the file you are importing timed out. Please try your import again. If your import continues to time out, please email [email protected].
<div class="mds-notification">
<div role="alertdialog" class="mds-notification__item mds-notification__item--error">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#alert">
<title>Error</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<strong class="mds-notification__title">Import Failure</strong>
<p class="mds-notification__message">We‘re sorry, the file you are importing timed out. Please try your import again. If your import continues to time out, please email <a href='#'>[email protected]</a>.</p>
<button class="mds-button mds-button--small mds-button--secondary" type="button">
Try Again
</button>
</div>
</div>
</div>
</div>
<mds-notification-group>
<mds-notification visible role="alertdialog" title="Import Failure" status="error" dismissible=false>
We‘re sorry, the file you are importing timed out. Please try your import again. If your import continues to time out, please email <a href='#'>[email protected]</a>.
<mds-button slot="mds-notification-custom-action" variation="secondary" size="small">Try Again</mds-button>
</mds-notification>
</mds-notification-group>
mds-notification--tinted
modifier class or the tinted
prop.Use for a message requiring attention but not resolution in order to continue, such as sharing a file with someone who does not have permissions to view it.
The user you are attempting to share a file with doesn‘t have permission to view it. Please contact your customer service consultant if you believe this is a mistake.
The user you are attempting to share a file with doesn‘t have permission to view it. Please contact your customer service consultant if you believe this is a mistake.
The user you are attempting to share a file with doesn‘t have permission to view it. Please contact your customer service consultant if you believe this is a mistake.
<div class="mds-notification">
<div role="alert" class="mds-notification__item mds-notification__item--warning mds-notification__item--dismissible">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#alert">
<title>Warning</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<strong class="mds-notification__title">Permissions Issue</strong>
<p class="mds-notification__message">The user you are attempting to share a file with doesn‘t have permission to view it. Please contact your customer service consultant if you believe this is a mistake.</p>
</div>
</div>
<button class="mds-button mds-notification__dismiss-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="#remove--s">
<title>Close</title>
</use>
</svg>
</button>
</div>
</div>
<mds-notification-group>
<mds-notification visible role="alertdialog" title="Permissions Issue" status="warning">
The user you are attempting to share a file with doesn‘t have permission to view it. Please contact your customer service consultant if you believe this is a mistake.
</mds-notification>
</mds-notification-group>
mds-notification--tinted
modifier class or the tinted
prop.Use for successes and completions, such as a report-generation or file upload completion, sent message confirmation, successfully adding investments to a list, or successfully saving updated settings.
116 investments have been added to your list.
116 investments have been added to your list.
116 investments have been added to your list.
<div class="mds-notification">
<div role="alertdialog" class="mds-notification__item mds-notification__item--success mds-notification__item--dismissible">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#check">
<title>Success</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<p class="mds-notification__message">116 investments have been added to your list.</p>
<button class="mds-button mds-button--small mds-button--secondary" type="button">
Undo
</button>
</div>
</div>
<button class="mds-button mds-notification__dismiss-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="#remove--s">
<title>Close</title>
</use>
</svg>
</button>
</div>
</div>
<mds-notification-group>
<mds-notification visible role="alertdialog" status="success">
116 investments have been added to your list.
<mds-button slot="mds-notification-custom-action" variation="secondary" size="small">Undo</mds-button>
</mds-notification>
</mds-notification-group>
mds-notification--tinted
modifier class or the tinted
prop.Use for immediate feedback that a background process is happening. For example, a report is being generated or a file is being imported.
We‘ll let you know as soon as it‘s finished.
We‘ll let you know as soon as it‘s finished.
<div class="mds-notification">
<div role="alert" class="mds-notification__item mds-notification__item--dismissible">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#info-circle">
<title>Information</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<strong class="mds-notification__title">Your Report Is Being Generated</strong>
<p class="mds-notification__message">We‘ll let you know as soon as it‘s finished.</p>
</div>
</div>
<button class="mds-button mds-notification__dismiss-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="#remove--s">
<title>Close</title>
</use>
</svg>
</button>
</div>
</div>
<mds-notification-group>
<mds-notification visible role="alertdialog" title="Your Report Is Being Generated" dismissible>
We‘ll let you know as soon as it‘s finished.
</mds-notification>
</mds-notification-group>
Sizing affects text size, icon size, and internal padding. The default size is medium, you can use modifier classes or props to make the notification smaller.
<div class="mds-notification">
<div role="alertdialog" class="mds-notification__item mds-notification--small mds-notification__item--dismissible">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#info-circle--s">
<title>Information</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<strong class="mds-notification__title">Notification Title</strong>
<p class="mds-notification__message">Notification message, including <a href='#'>a link</a>.</p>
<ul class="mds-notification__list">
<li class="mds-notification__list-item">List Item 1</li>
<li class="mds-notification__list-item">List Item 2</li>
</ul>
<button class="mds-button mds-button--small mds-button--secondary" type="button">
Take Action
</button>
</div>
</div>
<button class="mds-button mds-notification__dismiss-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="#remove--s">
<title>Close</title>
</use>
</svg>
</button>
</div>
</div>
<mds-notification-group>
<mds-notification visible list='["List Item 1", "List Item 2"]' role="alertdialog" size="small" title="Notification Title" dismissible>
Notification message, including <a href='#'>a link</a>
<mds-button slot="mds-notification-custom-action" variation="secondary" size="small">Take Action</mds-button>
</mds-notification>
</mds-notification-group>
Available in two widths, 350px
and 500px
. The default width is 500px
, you can use modifier classes or props to reduce the notification's width.
Medium notification using the 350px width.
Medium notification using the default 500px width.
<div class="mds-notification mds-notification--width-350px">
<div role="alert" class="mds-notification__item mds-notification__item--dismissible">
<div class="mds-notification__status">
<svg class="mds-icon mds-notification__icon">
<use xlink:href="#info-circle">
<title>Information</title>
</use>
</svg>
</div>
<div class="mds-notification__body">
<div class="mds-notification__content">
<strong class="mds-notification__title">Medium Notification Title</strong>
<p class="mds-notification__message">Medium notification using the 350px width.</p>
</div>
</div>
<button class="mds-button mds-notification__dismiss-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="#remove--s">
<title>Close</title>
</use>
</svg>
</button>
</div>
</div>
<mds-notification-group width="350px">
<mds-notification visible role="alertdialog" title="Medium Notification Title" dismissible>
Medium notification using the 350px width.
</mds-notification>
</mds-notification-group>
z-index
value when you compose this component with other layered components, e.g., Dialogs, Modals, Popovers or Tooltips to meet your product requirements. $mds-box-shadow-drop
, to float in front of page content.Place notifications at the top center of the viewport to ensure maximum visibility. Consider using this placement for error, warning, and success notifications.
mds-notification--below-masthead
or mds-notification--below-masthead-tall
modifier class or the mastheadPadding
prop to position notifications below the Masthead, so as not to obscure branding.$mds-space-2-x
(16px) between the Masthead and notification.$mds-space-stack-1-x
(8px) between notifications.Place notifications at the bottom right corner of the viewport to avoid disrupting a user’s focus. Consider using this placement for informational notifications.
position
prop to "bottom-right"
to achieve this placement.$mds-space-2-x
(16px) to separate notifications from the edge of the browser window.$mds-space-stack-1-x
(8px) between notifications.All the behaviors documented here come built into the notification web component. If you are using the HTML version of the component, you need to implement these behaviors yourself.
Contains a message only, may include a title and/or unordered list.
Contains message, and may include a link, custom action button, and/or unordered list. Use this behavior to ensure a user has an opportunity to act.
For additional editorial guidance, refer to Buttons and Errors documentation.
Class
|
Applies to
|
Outcome
|
---|---|---|
|
|
Creates a wrapper to hold all notifications within a single location. |
|
|
Applies top padding to ensure that all notifications are below the Masthead. |
|
|
Applies top padding to ensure that notifications are below the Tall Masthead. |
|
|
Toggles visibility of a notification wrapper. |
|
|
Modifies the maximum width from 500px to 350px. |
|
|
Reduces text size, icon size, and internal padding. |
|
|
Positions the notification at the top center of the viewport. |
|
|
Positions the notification at the bottom right of the viewport. |
|
|
Adds padding to the right side of the body of the notification to accommodate the close icon. |
|
|
Invokes a notification by setting the |
|
|
Dismisses the notification by animating a fade-out effect. |
|
|
Applies the green background color and the white icon color to the left side of the component. |
|
|
Applies the yellow background color and the black icon color to the left side of the component. |
|
|
Applies the red background color and the white icon color to the left side of the component. |
|
|
Applies the tinted background color to the body of the component. |
Notifications are comprised of two separate web components, each with a dedicated API:
<mds-notification>
elements. It also wraps multiple <mds-notification>
elements, allowing them to consistently stack. When setting props as attributes on a custom HTML element, use kebab-case
instead of camelCase
.
Prop
|
Type
|
Validation
|
Default
|
Description
|
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
String |
One of: |
— |
Sets the aria-live attribute. |
|
Number |
Only valid when |
|
The time in milliseconds before the notification is automatically dismissed. |
|
Boolean |
— |
|
If |
|
String |
— |
|
Sets the |
|
Array |
— |
— |
Sets the list content. |
|
Boolean |
Only valid when |
|
When |
|
String |
One of: |
|
|
|
String |
One of: |
|
Alters the size of the notification. |
|
String |
One of: |
|
Sets the status of the alert. |
|
String |
Required |
— |
The text for the notification. Can also be passed via the default slot. |
|
Boolean |
Only valid when |
|
When |
|
String |
— |
— |
Sets the title text of the notification. |
|
Boolean |
— |
false |
Sets the visibility of the notification. |
Pass text in between the <mds-notification></mds-notification>
tags to set the notification’s text content. This can be overridden with the text
prop.
Slot Name
|
Description
|
---|---|
|
Displays actions, usually Buttons, at the bottom of the notification. |
Method Name
|
Description
|
---|---|
|
Opens the notification. |
|
Closes the notification. |
Event Name
|
Description
|
---|---|
|
Triggers when the notification is opened. |
|
If |
|
If |
Setting dismissible
and visible
via props. Using the default slot for text
content:
<mds-notification dismissible visible> Notification Text </mds-notification>
Setting dismissible
via props. Using named slots for mds-notification-custom-action
. Using the default slot for text
content:
<mds-notification dismissible>
Notification Text
<mds-button slot="mds-notification-custom-action" variation="secondary" size="small"> Try Again </mds-button>
</mds-notification>
When setting props as attributes on a custom HTML element, use kebab-case
instead of camelCase
.
Prop
|
Type
|
Validation
|
Default
|
Description
|
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
String |
One of: |
— |
Sets the top padding of the notification group to properly space notifications below the Masthead component. |
|
String |
One of: |
|
Sets the position of contained notifications within the viewport. |
|
String |
One of: |
|
Alters the width of contained notifications. |
Pass <mds-notification>
custom elements between the <mds-notification-group></mds-notification-group>
tags to set the items in the notification group.
Setting masetheadPadding
, position
and width
via props. Using the default slot for the notifications in the group:
<mds-notification-group mastheadPadding="below-masthead" postion="top-center" width="350px">
<mds-notification visible> Notification Text </mds-notification>
<mds-notification visible> Notification Text </mds-notification>
</mds-notification-group>
role="alert"
attribute on the mds-notification
element.role="alertdialog"
when the notification also provides interactive controls, such as an “Undo” button, that provide feedback and dismiss the notification.