| Install | |
|---|---|
composer require superbyte23/sileo-livewire |
|
| Latest Version: | v1.0.0 |
| PHP: | ^8.2 |
Sileo toast notifications for Livewire 4. Beautiful gooey spring-physics toasts with a simple PHP trait API.
Powered by Sileo — a tiny, opinionated React toast component.
composer require superbyte23/sileo-livewire
npm install sileo react react-dom @vitejs/plugin-react
// vite.config.js
import { defineConfig } from 'vite'
import laravel from 'laravel-vite-plugin'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
react(),
],
})
php artisan vendor:publish --tag=sileo-livewire-js
This copies sileo-bridge.js into resources/js/.
{{-- resources/views/layouts/app.blade.php --}}
<livewire:sileo-toaster position="top-right" />
Available positions: top-left top-center top-right bottom-left bottom-center bottom-right
Add the HasSileoToasts trait to any Livewire component:
use Superbyte23\SileoLivewire\Concerns\HasSileoToasts;
use Livewire\Component;
new class extends Component
{
use HasSileoToasts;
public function save(): void
{
$this->toastSuccess('Saved!', 'Your changes were persisted.');
}
}
// Basic
$this->toastSuccess('Title', 'Description');
$this->toastError('Title', 'Description');
$this->toastWarning('Title', 'Description');
$this->toastInfo('Title', 'Description');
// Action button
$this->toastAction(
type: 'info',
title: 'Item deleted',
description: 'The record has been removed.',
actionLabel: 'Undo',
actionEvent: 'undo-delete', // Livewire event dispatched on click
actionParams: [42], // optional params
);
// Promise (loading → success/error)
$this->toastPromise(
event: 'run-save',
loading: 'Saving…',
success: 'All saved!',
error: 'Save failed.',
);
$this->resolveToastPromise('run-save'); // call when done
$this->rejectToastPromise('run-save'); // call on failure
// Custom position per toast
$this->dispatch('sileo', type: 'success', title: 'Done!', position: 'bottom-center');
#[\Livewire\Attributes\On('run-save')]
public function runSave(): void
{
try {
// ... your save logic ...
$this->resolveToastPromise('run-save');
} catch (\Throwable) {
$this->rejectToastPromise('run-save');
}
}
Sileo intentionally inverts the theme — dark page shows light toasts, light page shows dark toasts. Theme is detected from the .dark class on <html>, applied server-side (e.g. Flux, maryUI, Filament).
MIT — superbyte23