---
schema_version: "1"
id: b532218da12da651915b8594518a34ef9d3afc5afc580c212936bc14a5df4e00
title: Show Toast
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/aura/components/force/showToast/force-show-toast.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/force-show-toast.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 106db6d9067b23d331326732ab1af41ed7fe46aa490514cf557b9cdf88325597
products:
  - Lightning Component Reference
---
# Show Toast

**`force:showToast`**

Displays page-level toasts.

**For Use In**

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

A toast displays a message below the header at the top of a view. The message is specified by the `message` attribute.

`force:showToast` isn't available on login pages.

This example displays a toast message "Success! The record has been updated successfully."

```javascript
showToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        "title": "Success!",
        "message": "The record has been updated successfully."
    });
    toastEvent.fire();
}
```

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 20000ms, 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.

```javascript
showMyToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        mode: 'sticky',
        message: 'This is a required message',
        messageTemplate: 'Record {0} created! See it {1}!',
        messageTemplateData: ['Salesforce', {
            url: 'http://www.salesforce.com/',
            label: 'here',
            }
        ]
    });
    toastEvent.fire();
}
```

The following modes are supported.

- `dismissible`: Remains visible until you press the close button or `duration` has elapsed, whichever comes first.
- `pester`: Remains visible until `duration` has elapsed. No close button is displayed.
- `sticky`: Remains visible until you press the close buttons.

We recommend using [`lightning:notificationsLibrary](/docs/platform/lightning-component-reference/guide/lightning-notifications-library.html) for displaying messages in the app via notices and toasts.


:::::

:::::tab
## Attributes

| 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 20000ms. If you provide a value that's less than 20000ms, the value is raised to 20000ms per [WCAG 2.2.1](https://www.w3.org/WAI/WCAG21/Understanding/timing-adjustable.html). | 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   |         | ![Yes](https://developer.salesforce.com/media/check.png) |
| `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   |         |                                              |

:::::

::::::
