Show Toast
force:showToast
Displays page-level toasts.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App
A toast displays a message below the header at the top of a view. The message is specified by the message attribute.
force:showToast is not available on login pages.
This example displays a toast message "Success! The record has been updated successfully."
This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce mobile app, and Aura-based Experience Builder sites.
The background color and icon used by a toast is controlled by the type attribute. For example, setting it to success displays the toast notification with a green background and checkmark icon. This toast displays for 5000ms, with a close button in the top right corner when the mode attribute is dismissible.
While message supports a text-only string, messageTemplate supports a string containing links. You can provide a string with placeholders, which are replaced by labels provided in messageTemplateData. The parameters are numbered and zero-based. For example, if you have three parameters, {0}, {1}, and {2}, the labels are substituted in the order they're specified. The label is also used for the title attribute on the anchor tag.
This example displays a toast with a message that contains a link.
The following modes are supported.
dismissible: Remains visible until you press the close button ordurationhas elapsed, whichever comes first.pester: Remains visible untildurationhas elapsed. No close button is displayed.sticky: Remains visible until you press the close buttons.
We recommend using `lightning
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
duration | Length of time the toast is visible for, in milliseconds. Applies to 'dismissible' or 'pester' toast modes. The default is 5000ms if the provided value is less than 5000ms. | integer | ||
key | Icon to use when toast type is 'other'. Icon keys are available at the Lightning Design System Icons page. | string | ||
message | The message to display in the toast. | string | ![]() | |
messageTemplate | Overwrites message string with the specified message. Requires messageTemplateData. | string | ||
messageTemplateData | An array of text and actions to be used in messageTemplate. | object[] | ||
mode | The toast mode, which controls how users can dismiss the toast. Valid values are 'pester' and 'sticky'. The default is 'dismissible', which displays the close button. | string | ||
title | Specifies the title for a message to display. The title is shown above the message in a slightly larger font. | string | ||
type | The toast type, which can be 'error', 'warning', 'success', or 'info'. The default is 'other', which is styled like an 'info' toast and doesn’t display an icon, unless specified by the key attribute. | string |
