ascsoftw / livewire-toast
Livewire Package to display Toast Notifications
Installs: 535 016
Dependents: 1
Suggesters: 0
Security: 0
Stars: 48
Watchers: 1
Forks: 13
Open Issues: 3
Requires (Dev)
- livewire/livewire: ^2.4
- orchestra/testbench: ^6.17
README
Livewire Package to display Toast Notification based on TALL Stack.
Requirements
Make sure that Livewire is installed properly on your project.
Make sure that TailwindCSS is installed properly on your project.
Make sure that AlpineJS is installed properly on your project.
Installation
You can install the Package using Composer
composer require ascsoftw/livewire-toast
Usage
Put Livewire-component @livewire('livewire-toast')
anywhere into your app layout.
You can then call the Livewire Toast as below:
From Livewire Component
$this->emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message $this->emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported $this->emitTo('livewire-toast', 'show', ['type' => 'warning', 'message' => 'This is warning!']); //Can also pass type and message as array
Using Session Flash
session()->flash('livewire-toast', 'Project Added Successfully'); session()->flash('livewire-toast', ['type' => 'error', 'message' => 'There was an Error!']);
From Livewire View
$emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message $emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported $emitTo('livewire-toast', 'show', {'type' : 'warning', 'message' : 'This is warning!'}); //Can also pass type and message as object
From JS
Livewire.emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message Livewire.emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported Livewire.emitTo('livewire-toast', 'show', {'type' : 'warning', 'message' : 'This is warning!'}); //Can also pass type and message as object
Configurations
If you want to override the configurations, you must publish the assets using below command
php artisan vendor:publish --tag=config
This will publish the configuration file at config/livewire-toast.php
. You can override any configurations.
You can also publish the View using below command
php artisan vendor:publish --tag=views
This will publish the Views in resources/views/vendor/livewire-toast
directory which you can then customize.
Troubleshooting
Your messages don't get styles while using TailwindCss? Please publish your view. Therefore Laravel Mix compiler will find package related views and will purge CSS accordingly.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.