I am displaying a toast message showing errors when the user submits the form. The errors are displayed with a x to close the panel. However, the x isn't closing it, and I would like to close the toast message automatically when the user fixes the errors and submits the form again.

1 Answer 1


There is no API for closing a toast. However, you can specify a duration for the toast:

var toast = $A.get("e.force:showToast");
toast.setParams({ message: someMessage, duration: 5000 });
  • Thanks sfdcfox, the requirement is to leave the box until the user has read it all and fixed the errors and resubmit. if I launch another toast message for a quick millisecond, would the first one go away? i assume you can have one toast msg at a time?
    – Sheida
    May 25, 2017 at 21:18
  • @Sheida Toasts are not meant to do that, and are not designed to support that. You'll have to create a component and show it using CSS. Toasts cannot be displayed for fewer than 5000 ms (it'll be bumped up to 5000 if you try). Also, toasts are placed in a queue, so the second wouldn't overwrite the first anyways.
    – sfdcfox
    May 25, 2017 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .