Skip to content

CdsNotificationAlert

Deprecated

A pop-up notification above the page — the counterpart of CdsNotificationAlert from CDS 3. It is assembled from CdsOverlay and CdsNotification in the important variant; it hides automatically after timeout, while hovering the cursor or focusing inside pauses the timer.

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

The component exists only for a smooth migration from CDS 3 and will be removed. For new scenarios use CdsToast.

Variations ​

Controlling the display ​

Visibility is controlled through v-model or the activator slot — the element inside the slot opens the notification on click. The text comes from the text prop.

Statuses ​

The status prop sets the color of the content and the icon: info, success, warning, danger, progress. The icon can be replaced by the icon prop or hidden with the value false.

Positions ​

The location prop sets the position on the screen: the side (top, bottom) and the alignment (left, center, right).

Auto-closing ​

The timeout prop controls the auto-close delay in milliseconds, 5000 by default. The values -1 and 0 turn auto-closing off — the notification stays until the user closes it (closable). Hovering the cursor and focusing inside pause the countdown.

Scenarios ​

Undoing an action ​

After an irreversible operation the notification gives a short window to undo it: the button in the actions slot closes it through v-model, and an increased timeout leaves time to change one's mind.

A stack of notifications ​

Every instance is an independent overlay: notifications sharing a position pile up into a vertical stack. On close (update:model-value → false) remove the item from the list.

API ​

Props

NameTypeDefaultDescription
absoluteboolean | undefined—Positions the element absolutely instead of fixed. This is useful for overlays that must stay inside a certain area, for example inside a container with position: relative.
activator(string & {}) | Element | "parent" | ComponentPublicInstance | undefined—The element that activates the component
activatorPropsRecord<string, any> | undefined{}Props for the activator element
attachstring | boolean | Element | undefined—Sets the DOM element the overlay content is moved to. It accepts a direct element reference, a querySelector string, or true to disable moving. By default the body element is used. Changing this prop is usually not recommended except for edge cases: the default positioning algorithm handles most scenarios better than it can without moving, and unexpected behavior may appear if the menu ends up being a child of its activator.
bgColorstring | undefined—Background color of the component
closableboolean | undefined—Adds a close button that hides the notification.
closeDelaystring | number | undefined—Delay in milliseconds before the component closes. Works only together with open-on-hover.
closeIconIconValue | undefined'close'Icon of the close button.
closeLabelstring | undefined'$cds.close'Accessible label (aria-label) for the close button.
closeOnBackboolean | undefinedfalseCloses the overlay content when the browser Back button is pressed or $router.back() is called, cancelling the original navigation. persistent overlays cancel the navigation and animate as if they were clicked outside instead of closing.
closeOnContentClickboolean | undefined—Hide the component on a click on the content
containedboolean | undefined—Limits the size of the component and of its grid to the offset parent. Implies the absolute and attach props. (Note: the parent element must have position: relative.)
contentstring | number | undefined—Content displayed in the component.
contentClassany—Applies a custom class to the content element. This is handy because the content is moved to the beginning of the cds-app component (unless attach is set) and cannot be selected with classes passed to the component directly.
contentPropsany—Applies custom props to the moved content
disabledboolean | null | undefinednullDisabled state
eagerboolean | undefined—Renders the content of the component right away. Useful when you have content that is not in the DOM but has to be indexed for SEO.
heightstring | number | undefined—Component height
iconfalse | IconValue | undefinednullIcon before the content. Taken from status by default; false hides the icon.
locationAnchor | null | undefined'top center'Position of the element relative to its container, for example "top left", "center", "bottom right".
locationStrategy"static" | "connected" | LocationStrategyFunction | undefined'static'Sets the way the overlay content is positioned. By default static is used, which centers the content in its container. Use connected to attach the content to the activator element.
maxHeightstring | number | undefined—Maximum component height
maxWidthstring | number | undefined—Maximum component width
minHeightstring | number | undefined—Minimum component height
minWidthstring | number | undefined—Minimum component width
modelValueboolean | undefined—The v-model value of the component. If the component supports the multiple prop, an empty array is used by default.
opacitystring | number | undefined—Opacity of the scrim element. Applies only when scrim=true.
openDelaystring | number | undefined—Delay in milliseconds before the component opens. Works only together with open-on-hover.
openOnClickboolean | undefined—Show the component on a click on the activator
openOnFocusboolean | undefined—Show the component when the activator gets focus
openOnHoverboolean | undefined—Show the component on hover over the activator
originAnchor | "auto" | "overlap" | undefined'auto'Sets the anchor point of the overlay content that is aligned with the location anchor of the target. With "auto" the opposite side of the location point is used. With "overlap" the same anchor point is used, so the overlay overlaps the target. It also sets the CSS transform-origin property for the enter/leave transitions.
position"absolute" | "static" | "fixed" | "relative" | "sticky" | undefined—CSS positioning of the component — the value of the position property
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
target(string & {}) | Element | "parent" | ComponentPublicInstance | "cursor" | [x: number, y: number] | undefined—When locationStrategy is set to "connected", specify the element or the array of x, y coordinates the overlay is positioned against. By default the activator element is used.
textstring | number | undefined—Text displayed in the component.
textColorstring | undefined—Text color of the component
themestring | undefined—Component theme
timeoutstring | number | undefined5000Delay in milliseconds before the notification hides automatically. The values -1 and 0 turn auto-closing off.
titlestring | undefined—Notification heading.
transitionstring | boolean | (TransitionProps & { component?: Component | undefined; }) | null | undefined'notification-transition'Transition animation
variant"default" | "flat" | "compact" | "important" | undefined'important'Appearance of the notification. important by default — an elevated surface with a shadow (the CdsNotificationAlert look).
widthstring | number | undefined—Component width
zIndexstring | number | undefined2000The z-index value of the component.

Events

NameTypeDescription
click:close[event: MouseEvent]Click on the close button.
update:modelValue[value: boolean]The visibility of the notification changed.

Slots

NameTypeDescription
actionsanySlot for actions (buttons, links) below the text.
activator{ isActive: boolean; props: Record<string, any>; }Activator slot that controls the display of the notification.
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).

Exposed

NameTypeDescription
activatorElHTMLElement | undefinedThe DOM element of the activator.
activatorRefTemplateRefTemplate ref for assigning the activator manually.
animateClick() => voidRuns the bounce animation of the content — the same as on a click outside a persistent overlay.
contentElHTMLElement | undefinedThe DOM element of the overlay content.
globalTopbooleanWhether the overlay is the top one in the global stack of open overlays.
rootElHTMLElement | undefinedThe root DOM element of the overlay.
scrimElHTMLElement | undefinedThe DOM element of the scrim that dims the page.
targetElHTMLElement | undefinedThe DOM element of the positioning target.
targetRefTemplateRefTemplate ref for assigning the positioning target manually.
updateLocation((e: Event) => void) | undefinedRecalculates the position of the content relative to the target.