-
-
Notifications
You must be signed in to change notification settings - Fork 86
Notification trait
This package includes a Livewire notification trait that you can use in anywhere in your project. (Without making a form). By default the form component shows a Saved!
message next to the Save and stay
button on the form save()
method. The following instructions are for extended use in the rest of your project.
(Please observe that you can only use the notification trait from within a Livewire component.)
If you also want to show a notification when a form is saved OR if you want to show notifications anywhere in your project you have to add the included Laravel 7 blade component to your layout file and call the notify()
method in a livewire component. You can also call this method in AlpineJS.
<x-tall-notification />
Don't add this to a form component (Already applied)
use Tanthammar\TallForms\Traits\Notify;
//call this in any Livewire component method
$this->notify($type, $message, $icon, $iconcolor);
// Via browser event
$this->notify('success', 'Record updated');
// To session
$this->withSession()->notify('success', 'Record updated');
Background colors are defined in config file. Also see Tailwind setup
Available options:
- positive
- negative
- info
- warning
-
null
Omitting the property uses thedefault
color from the config file.
/* Notification */
.tf-notify-bg-default {
@apply bg-teal-400;
}
You can use this trait in both php or in frontend js. You can either set a LiveWire property that calls the notify method or you can call the notify method directly.
Don't add this to a form component (Already applied)
use Tanthammar\TallForms\Traits\Notify;
Example js to update the property
@this.set('alert', {
type: 'negative',
message: "Your notification message"
});
Example js to call the notify method directly
@this.call('notify', 'negative', 'Oh No!');
- Installation
- Requirements
- v5 Upgrade Guide
- v6 Upgrade Guide
- v7 Upgrade Guide
- Support
- Quickstart
- Manual installation
- Optional
- Form component
- Field
- Field types
- Example Form
- Blade Components
- Notifications