Skip to content
This translation may be outdated: the Russian source changed after it was translated.Open the Russian version

CdsNotification

A notification is a block with a message about an event or a state: a successful save, a warning about a limit, a loading error. The semantic status sets the color and the icon, and the display modes let you embed the message into a form, a card or a list.

Storybook GitLab Figma
Test coverage: 100% — good coverage
API in specs
23 / 23 props, events, slots and exposed members with a test
Test cases
49 unit · 0 browser
Known bugs
1 pinned by an it.fails test
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
4 recommendations in 11 stories measured in v4.0.0-alpha.11

For pop-up messages above the page that disappear on their own take CdsToast. For a short status label in a row or a card — CdsTag.

Anatomy ​

A notification consists of a status icon, a content column — heading, text and actions — and a close button. Every part can be replaced by the slot of the same name.

Variations ​

Statuses ​

The status prop sets the semantics of the message — its color and its icon. The default status is info.

Display modes ​

The variant prop changes the styling: default — with a border, flat — without a border, compact — a single line, important — a neutral background and a shadow for showing above the content.

variant="compact" puts the icon, the text and the actions on one line and hides the heading. It fits tight places: a filter panel, a table row, the footer of a card.

Icons ​

By default the icon matches the status. The icon prop replaces it with any icon from the pack, and the value false removes it altogether.

Closing ​

The closable prop adds a close button; the visibility of the notification is controlled through v-model. A click on the button also emits click:close.

The notification appears and leaves smoothly: it fades out first, then collapses in height, so neighbouring blocks slide without a jump. click:close is emitted right at the click, while update:modelValue arrives after the leave has finished, so you can remove the item from a list in the handler without cutting the animation short. Set the spacing between notifications in a list with margin: it collapses together with the block, unlike gap, which makes a jump on leave. Under prefers-reduced-motion only opacity changes.

Slots ​

Slots replace the content coming from props when you need your own markup.

SlotDescription
prependContent before the text. Replaces the status icon
titleHeading. Replaces the text from title
textMessage text. Replaces the text from text
defaultArbitrary content after the text
actionsActions (buttons, links) below the text
appendContent after the content column
closeClose button. Receives props to bind to your own element

Guidelines ​

Scenarios ​

Form submission result ​

After a successful request a notification with the success status appears through v-model and confirms the result. The closable prop lets the user dismiss the message once it is read.

A warning with an action ​

A warning notification does not just report a problem — it offers a solution right away with a button in the actions slot. On click the status changes to progress, and after the server responds — to success: the user sees the whole course of the operation in a single block.

Loading error with a retry ​

If the data failed to load, a danger notification explains what happened and offers to repeat the request. The progress status shows that the retry is already running.

API ​

Props

NameTypeDefaultDescription
bgColorstring | undefined—Background color of the component
closableboolean | undefined—Adds a close button that hides the notification.
closeIconIconValue | undefined'close'Icon of the close button.
closeLabelstring | undefined'$cds.close'Accessible label (aria-label) for the close button.
contentstring | number | undefined—Content displayed in the component.
iconfalse | IconValue | undefinednullIcon before the content. Taken from status by default; false hides the icon.
modelValueboolean | undefinedtrueVisibility of the notification (v-model). When false, the notification is not rendered.
status"progress" | "danger" | "success" | "warning" | "info" | undefined'info'Semantic status — drives the color and the default icon.
tagstring | JSXComponent<any> | undefined'div'Custom HTML tag or component to render
textstring | number | undefined—Text displayed in the component.
textColorstring | undefined—Text color of the component
themestring | undefined—Component theme
titlestring | undefined—Notification heading.
variant"default" | "flat" | "compact" | "important" | undefined'default'Display mode: default — regular; flat — borderless; compact — single line without a heading; important — neutral background and a shadow, where the status only drives the content colors.

Events

NameTypeDescription
click:close[event: MouseEvent]Click on the close button.
update:modelValue[value: boolean]The visibility of the notification changed. On close by the button it arrives after the leave animation ends, not at the click.

Slots

NameTypeDescription
actionsanySlot for actions (buttons, links) below the text.
appendanySlot after the content.
close{ props: Record<string, any>; }Close button slot; receives props to bind to your own element.
defaultanyMain content of the notification (complements text).
prependanySlot before the content (the status icon by default).
textanyText slot (instead of the text prop).
titleanyHeading slot (instead of the title prop).