useToast composable.
Installation
First, install the Vue 3 package:Setup
1
Register the plugin
2
Add the Toasts component
Place the
<Toasts /> component in your root layout file (e.g., Layout.vue):Using the composable
TheuseToast composable provides methods to programmatically create toasts from your Vue components.
Basic usage
Available methods
TheuseToast composable returns an object with the following methods:
success(message, options?)
Displays a success toast.
error(message, options?)
Displays an error toast.
info(message, options?)
Displays an info toast.
warning(message, options?)
Displays a warning toast.
Toast options
You can customize individual toasts using theoptions parameter:
TypeScript support
The package is written in TypeScript and includes full type definitions:Advanced usage
Direct store access
For advanced use cases, you can access the toast store directly:Next steps
Styling
Customize the appearance of your toasts
Laravel setup
Configure Laravel to send toast notifications