Signature
Returns
Returns thetoast function from Sonner with all its methods:
Main toast function for displaying messages
Usage
Basic Toast
Success Toast
Error Toast
Loading Toast
Promise Toast
Toast with Description
Toast with Action
Dismissing Toasts
Toast Options
All toast methods accept an optional options object:Example: Form Submission
Best Practices
- Keep messages concise: Toast messages should be brief and scannable
- Use appropriate variants: Choose the right variant (success, error, warning) for the context
- Provide actionable feedback: Include action buttons when users can respond (e.g., “Undo”)
- Don’t overuse: Avoid showing multiple toasts simultaneously for unrelated actions
- Set appropriate duration: Longer messages may need longer display time