Skip to content

Notification

Notification

Dispatch a notification

notification example

Usage:

ts
function alertYes() {
  alert('Yes');
}

sw.notification.dispatch({
    title: 'Your title',
    message: 'Your message',
    variant: 'success',
    appearance: 'notification',
    growl: true,
    actions: [
        {
            label: 'Yes',
            method: alertYes
        },
        {
            label: 'No',
            method: () => {
                alert('No')
            }
        },
        {
            label: 'Cancel',
            route: 'https://www.shopware.com',
            disabled: false,
        }
    ]
})

Parameters:

NameRequiredDefaultDescription
titletrueDefines a notification's title.
messagetrueDefines a notification's main expression or message to the user.
variantfalseinfoDefines the notification type. Available variant types are success, info, warning and error.
appearancefalsenotificationChanges the style of a notification. Use system for technical notifications thrown by the application. Otherwise keep the default value notification.
growlfalsetrueDisplays a notification that is overlaying any module. Use false to display the notification in the notification center (bell symbol) only.
actionsfalse[]Adds clickable buttons to the notification. Each button with a label can trigger a method or open a route (internal route or external link). Buttons can also be disabled using the attribute disabled.

Return value:

Returns a promise without data.