Tail Alert is a lightweight Livewire alert package for Laravel, providing stylish toast notifications built with Tailwind CSS. It helps you display modern notifications easily in any Livewire component.
ā Modern and minimal design with Tailwind
ā Fully compatible with Livewire
ā Supports different alert types (success, warning, error, info)
composer require ab01faz101/tail-alert
php artisan vendor:publish --provider="Ab01faz101\TailAlert\TailAlertServiceProvider" --force
<link rel="stylesheet" href="{{asset('vendor/tail_alert/style.css')}}">
.tail_alert_item.active{
animation: tail_alert_item_move .4s;
}
.tail_alert_item.active .tail_alert_time_animation{
margin: 0!important;
animation: fullWidthAnimate 5s ease;
}
@keyframes fullWidthAnimate {
0%{
width: 0;
}
100%{
width: 100%;
}
}
@keyframes tail_alert_item_move {
0%{
transform: translateX(100%);
}
100%{
transform: translateX(0);
}
}
<script src="{{ asset('vendor/tail_alert/alert.js') }}"></script>
Before using this package, make sure to add the following path to your tailwind.config.js
file:
module.exports = {
content: [
// ...
"./public/vendor/tail_alert/alert.js",
],
theme: {
extend: {},
},
plugins: [],
};
@include('components.alerts')
Note: This package requires Tailwind CSS to be installed in your project.
use Ab01faz101\TailAlert\Traits\TailAlertTrait;
class Index extends Component
{
use TailAlertTrait;
public function submit()
{
$this->alert('success', 'Basic Alert');
}
}
In your Livewire component, you can trigger an alert like this:
$this->alert('success', 'alert message' , "description");
$this->alert('info', 'alert message' , "description");
$this->alert('warning', 'alert message' , "description");
$this->alert('error', 'alert message' , "description");
public function flashSuccess() {
session()->flash('alert', [
'type' => 'success',
'message' => 'Successful Operation!'
]);
}
public function flashError() {
session()->flash('alert', [
'type' => 'error',
'message' => 'An Error Occurred.'
]);
}
public function flashWarning() {
session()->flash('alert', [
'type' => 'warning',
'message' => 'Warning.'
]);
}
public function flashInfo() {
session()->flash('alert', [
'type' => 'info',
'message' => 'Information.'
]);
}
public function redirectAlert() {
return redirect()->route('test')->with('alert' , [
'type' => 'success',
'message' => 'mission successfully!'
]);
}
š” The type can be success
, error
, warning
, or info
.
Livewire Toast Notifications, Laravel Alerts, Tailwind CSS Alerts, Livewire Notifications, Laravel Toast
This package is released under the MIT License.