# How do you show a toast message in LWC?

**Topic:** Development · **Difficulty:** Easy · **Tags:** lwc, toast, ui

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-you-show-a-toast-message-in-lwc

## Answer

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.

---
Source: ForceChallenges · last updated 2026-10-19
