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.
| Slot | Description |
|---|---|
prepend | Content before the text. Replaces the status icon |
title | Heading. Replaces the text from title |
text | Message text. Replaces the text from text |
default | Arbitrary content after the text |
actions | Actions (buttons, links) below the text |
append | Content after the content column |
close | Close 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
| Name | Type | Default | Description |
|---|---|---|---|
bgColor | string | undefined | — | Background color of the component |
closable | boolean | undefined | — | Adds a close button that hides the notification. |
closeIcon | IconValue | undefined | 'close' | Icon of the close button. |
closeLabel | string | undefined | '$cds.close' | Accessible label (aria-label) for the close button. |
content | string | number | undefined | — | Content displayed in the component. |
icon | false | IconValue | undefined | null | Icon before the content. Taken from status by default; false hides the icon. |
modelValue | boolean | undefined | true | Visibility 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. |
tag | string | JSXComponent<any> | undefined | 'div' | Custom HTML tag or component to render |
text | string | number | undefined | — | Text displayed in the component. |
textColor | string | undefined | — | Text color of the component |
theme | string | undefined | — | Component theme |
title | string | 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
actions | any | Slot for actions (buttons, links) below the text. |
append | any | Slot after the content. |
close | { props: Record<string, any>; } | Close button slot; receives props to bind to your own element. |
default | any | Main content of the notification (complements text). |
prepend | any | Slot before the content (the status icon by default). |
text | any | Text slot (instead of the text prop). |
title | any | Heading slot (instead of the title prop). |