Development questions

How do you show a toast message in LWC?

DevelopmentEasy

Import ShowToastEvent and dispatch it:

javascript
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

this.dispatchEvent(new ShowToastEvent({
  title: 'Success',
  message: 'Record saved',
  variant: 'success', // info | success | warning | error
  mode: 'dismissable' // sticky | pester | dismissable
}));

Toasts work in Lightning Experience and the Salesforce mobile app, and in Experience Cloud sites that support them.

lwctoastui