Newer Version Available
force:showToast
A toast displays a message below the header at the top of a view. The message is specified by the message attribute.
This example displays a toast message “Success! The record has been updated successfully.”.
1showToast : function(component, event, helper) {
2 var toastEvent = $A.get("e.force:showToast");
3 toastEvent.setParams({
4 "title": "Success!",
5 "message": "The record has been updated successfully."
6 });
7 toastEvent.fire();
8}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.
| Attribute Name | Type | Description |
|---|---|---|
| title | String | Specifies the toast title in bold. |
| message | String | Required. Specifies the message to display. |
| key | String | Specifies an icon when the toast type is other. Icon keys are available at the Lightning Design System Resources page. |
| duration | Integer | Toast duration in milliseconds. The default is 5000ms. |
| type | String | 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. Available in API version 37.0 and later. |
| mode | String | The toast mode, which controls how users can dismiss the toast. The default is dismissible, which displays the close button. Available in API version 37.0 and later. |