Overview
ThemiscToastNotification component demonstrates how to display toast notifications using the ShowToastEvent from the lightning/platformShowToastEvent module.
Source Component
- miscToastNotification - Displays customizable toast notifications
Key Features
- Four variant types: error, warning, success, info
- Customizable title and message
- Platform-standard notification styling
- Event-based architecture
Implementation
Basic Toast
Import and dispatch theShowToastEvent:
Toast Variants
Four variants are available, each with different styling:- error - Red background, indicates errors
- warning - Orange background, indicates warnings
- success - Green background, indicates successful operations
- info - Blue background, indicates informational messages
Event Properties
TheShowToastEvent accepts these properties:
- title - Toast heading text
- message - Toast body message
- variant - Visual style (error, warning, success, info)
- mode - Display mode:
dismissable(default),pester, orsticky
Toast notifications are automatically dismissed after a few seconds unless the mode is set to
sticky. Users can also manually dismiss toasts by clicking the X button.Advanced Usage
Sticky Toast
Create a toast that persists until manually dismissed:Dynamic Messages
Bind toast properties to component state:Best Practices
- Use
successfor confirmations of completed actions - Use
errorfor failures that require user attention - Use
warningfor important information that isn’t critical - Use
infofor general notifications - Keep messages concise and actionable
Source Files
force-app/main/default/lwc/miscToastNotification/
