A customizable toast notification system that provides feedback to users with different types of messages.
// Basic usage
this.$toast.success('Operation completed successfully!')
// With title and custom duration
this.$toast.error('Upload failed', {
title: 'Error',
duration: 8000
})| Method | Parameters | Description |
|---|---|---|
| success | message, options | Shows a success toast notification |
| error | message, options | Shows an error toast notification |
| warning | message, options | Shows a warning toast notification |
| info | message, options | Shows an info toast notification |
| remove | id | Removes a specific toast by ID |
| clear | - | Removes all active toasts |
| Option | Type | Default | Description |
|---|---|---|---|
| title | String | - | Optional title for the toast |
| duration | Number | 5000 | Duration in milliseconds (0 = no auto-remove) |
The Toaster component supports 4 different types of notifications:
Used for successful operations and confirmations.
Used for errors, failures, and critical issues.
Used for warnings and important notices.
Used for general information and updates.
Common use cases and advanced examples:
Show multiple toasts at once to see the stacking behavior.
// In a Vue component
export default {
methods: {
handleSuccess() {
this.$toast.success('Operation completed successfully!')
},
handleError() {
this.$toast.error('Something went wrong!')
}
}
}// Toast with title and custom duration
this.$toast.error('Upload failed', {
title: 'Upload Error',
duration: 8000
})
// Persistent toast (no auto-remove)
this.$toast.warning('Please save your work', {
title: 'Important',
duration: 0
})// Store toast ID for later removal
const toastId = this.$toast.info('Processing...', { duration: 0 })
// Remove specific toast
this.$toast.remove(toastId)
// Clear all toasts
this.$toast.clear()