devrabiul/laravel-toaster-magic
Dependency-free toast notifications for Laravel with Livewire v3/v4 support. Drop-in, customizable toasts with multiple modern themes, RTL + dark mode, XSS-safe links, and no need for jQuery, Bootstrap, or Tailwind.
Release date: 2026-06-18 Type: Minor release — fully backward compatible
v2.3.0 is a "Motion & Avatars" release. It brings toasts to life with smooth, physics-aware stacking and configurable entrance/exit animations, and adds avatar/notification-style toasts for "new message" and "new follower" experiences. The package's scope is unchanged, and there are no breaking changes — the new default animation preserves the exact look and feel of v2.2, so existing apps upgrade without touching any code.
default, slide, fade, pop, bounce.prefers-reduced-motion — animations gracefully degrade for users who ask for less motion.Pass an avatar image URL in the options array to show an image instead of the type icon — perfect for chat, social, and activity notifications. The URL is sanitized before it's rendered.
ToastMagic::info('New message', 'Hey, are you free to chat?', [
'avatar' => $user->avatar_url,
]);
Also available from JavaScript (8th argument) and through Livewire event options:
// toastMagic.{type}(heading, description, showCloseBtn, customBtnText, customBtnLink, timeOut, showDuration, avatar)
toastMagic.info('New follower', 'Sarah started following you.', false, '', '', null, null, '/img/sarah.jpg');
A new animation config option controls how toasts move on and off screen:
// config/laravel-toaster-magic.php
'options' => [
'animation' => 'slide', // default, slide, fade, pop, bounce
],
| Value | Effect |
|---|---|
default |
Slide in from the toast's position (unchanged from v2.2) |
slide |
Same as default — explicit slide |
fade |
Fade in/out with no movement |
pop |
Scale up from slightly smaller, with a soft overshoot |
bounce |
Slide in with a springy overshoot |
When a toast is added or dismissed, the remaining toasts now glide smoothly into their new positions using the FLIP technique, rather than snapping. Stacking is position-aware: the newest toast always appears closest to the configured corner (on top for toast-top-*, at the bottom for toast-bottom-*), and the existing toasts animate to their new spots instead of being shoved.
This is purely visual polish — no API changes, and it honors prefers-reduced-motion.
toast-bottom-center) differently from the standard build. Both runtimes now share one consistent, position-aware rule.| Requirement | Supported |
|---|---|
| PHP | 8.0 – 8.5 |
| Laravel | 8 – 13 |
| Livewire | v3 & v4 |
No new requirements. The avatar and animation features are opt-in and degrade cleanly when unused.
composer update devrabiul/laravel-toaster-magic
No code changes required. The new default animation matches v2.2's behavior exactly.
Because v2.3 ships updated CSS and JavaScript, make sure the new assets are served. They auto-refresh on the next page load, or you can re-publish explicitly:
php artisan vendor:publish --tag=toast-magic-assets --force
To try the new features, add them to your config and/or calls:
// config/laravel-toaster-magic.php
'options' => [
'animation' => 'pop',
],
ToastMagic::success('Profile updated', 'Your account information has been saved.', [
'avatar' => auth()->user()->avatar_url,
]);
Thanks to everyone using and reporting issues on Laravel Toaster Magic. If it helps you in production, consider planting a tree. 🌱
Full changelog: see CHANGELOG.md.
Release date: 2026-06-17 Type: Minor release — fully backward compatible
v2.2.0 is a "Trust & Polish" release. The package's scope is unchanged — it still does one thing, beautiful toast notifications for Laravel — but it is now more reliable, better tested, more compatible, and more pleasant to use. No breaking changes: existing apps can upgrade without touching their code.
timeOut / showDuration for a single toast.toastMagic.clear() / toastMagic.dismissAll() from JavaScript.preventDuplicates now actually works.MessageBag support — pass $validator->errors() straight into a toast.ToastMagic::dispatch()->success(...).timeOut and showDuration can now be set per toast (in milliseconds), falling back to your global config when omitted:
ToastMagic::success('Saved!', 'Your changes are live.', [
'timeOut' => 10000, // keep this one on screen longer
'showDuration' => 300,
]);
Also supported through Livewire event options.
Toasts no longer disappear while a user is hovering over them. This is enabled by default. To restore the old always-auto-dismiss behavior, set:
// config/laravel-toaster-magic.php
'options' => [
'pauseOnHover' => false,
],
toastMagic.clear(); // dismiss all visible toasts
toastMagic.dismissAll(); // alias of clear()
ToastMagic::error($validator->errors());
The MessageBag is flattened into a single toast, one message per line.
ToastMagic::dispatch()->success('User Created', 'The user has been created.');
preventDuplicates is now honored by the JavaScript runtime — identical, currently-visible toasts (same type, heading, and description) are skipped when the option is enabled. Previously the option existed but did nothing.clear() now also clears already-queued messages from the session, not just the in-memory list.MessageBag passed to a toast type no longer throws a TypeError — the message-flattening path is now reachable.dispatch() example previously referenced a method that didn't exist; it now works as documented.The README's blanket "XSS Safe" wording has been corrected to be precise:
e() helper.ToastMagic::success('Welcome, ' . e($user->name) . '!');
Coming in v3.0.0: message content will be escaped by default, with an opt-in flag for intentional HTML.
| Requirement | Supported |
|---|---|
| PHP | 8.0 – 8.5 |
| Laravel | 8 – 13 |
| Livewire | v3 & v4 |
composer.json now declares these constraints explicitly, so Composer can warn you about an incompatible stack.
Note: CI verifies PHP 8.1–8.5 with Laravel 10–13. PHP 8.0 and Laravel 8/9 remain supported per the declared constraints but are not exercised in the automated matrix (no current Laravel release runs on PHP 8.0).
composer update devrabiul/laravel-toaster-magic
That's it — no code changes required. Assets are auto-refreshed on the next page load (or run php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider" to re-publish the config).
The only behavior change is pause-on-hover, which is on by default. If you specifically relied on toasts dismissing while hovered, set 'pauseOnHover' => false in your config.
Thanks to everyone using and reporting issues on Laravel Toaster Magic. If it helps you in production, consider planting a tree. 🌱
Full changelog: see CHANGELOG.md.
This release focuses on security hardening, bug fixes, and code quality improvements. No breaking changes — fully backward-compatible with v2.0.
customBtnLink values are now validated before being rendered into href attributes. Previously, a malicious value like javascript:... could execute arbitrary code when the button was clicked.
A sanitizeUrl() guard was added to both the standard and Livewire JS builds. Any URL that does not start with http://, https://, /, or # is automatically replaced with #.
Affected files:
assets/js/laravel-toaster-magic.jsassets/js/livewire-v3/laravel-toaster-magic.jsjavascript: Default in Livewire EventsThe Livewire event listener was using 'javascript:' as the default fallback for customBtnLink when none was provided. This has been replaced with an empty string, which correctly suppresses the button from rendering entirely.
php artisan migrate with Database Cache DriverFixes: #19
The service provider called Cache::rememberForever() during boot(). When CACHE_STORE=database, this immediately fired a SQL query against the cache table — but on a fresh installation the table doesn't exist yet, causing a fatal error that prevented php artisan migrate from running at all.
The fix wraps the cache call in a try-catch. If the cache driver throws for any reason (missing table, connection error, misconfigured driver), the value is computed directly without caching. Once migrations complete, normal caching resumes automatically.
// Before — crashes if cache table doesn't exist yet
$systemProcessingDirectory = Cache::rememberForever($cacheKey, $compute);
// After — falls back gracefully
try {
$systemProcessingDirectory = Cache::rememberForever($cacheKey, $compute);
} catch (\Throwable) {
$systemProcessingDirectory = $compute();
}
rtrim() Was Silently Corrupting Toast MessagesWhen building toast messages from a Laravel MessageBag, the code used rtrim($string, "<br>") to strip the trailing <br> separator. PHP's rtrim() treats its second argument as a character mask, not a string — meaning it was stripping any of the individual characters <, b, r, > from the right end of the message. Words like "error", "number", or "better" at the end of a validation message would be silently truncated.
Fixed with preg_replace('/(<br>)+$/', '', $string) across all four methods: info, success, warning, error.
closeButton OptionThe Livewire event listener only read showCloseBtn from event options, while the rest of the package used closeButton. Users passing closeButton: true in a Livewire dispatch would silently get no close button.
Both keys are now supported with a fallback chain — fully backward-compatible:
const showCloseBtn = detail?.options?.showCloseBtn ?? detail?.options?.closeButton ?? false;
str_replace('\n', ...) — single-quoted '\n' in PHP is a literal backslash-n, never a newline. The line was unreachable and has been removed.use Exception; import from ToastMagic.php.showDuration and timeOut in config/laravel-toaster-magic.php were stored as strings ("300", "5000"). They are now proper integers (300, 5000).closeButton and showCloseBtn integrations continue to workcomposer update devrabiul/laravel-toaster-magic
Then re-publish assets:
php artisan vendor:publish --tag=laravel-toaster-magic-assets --force
Assets are also auto-published on the next page load via the built-in version-diffing mechanism.
Laravel Toaster Magic is designed to be the only toaster package you'll need for any type of Laravel project. Whether you are building a corporate dashboard, a modern SaaS, a gaming platform, or a simple blog, I have crafted a theme that fits perfectly.
"One Package, Many Themes." — No need to switch libraries just to change the look.
This major release brings 7 stunning new themes, full Livewire v3/v4 support, and modern UI enhancements.
I have completely redesigned the visual experience. You can now switch between 7 distinct themes by simply updating your config.
| Theme | Config Value | Description |
|---|---|---|
| Default | 'default' |
Clean, professional, and perfect for corporate apps. |
| Material | 'material' |
Google Material Design inspired. Flat and bold. |
| iOS | 'ios' |
(Fan Favorite) Apple-style notifications with backdrop blur and smooth bounce animations. |
| Glassmorphism | 'glassmorphism' |
Trendy frosted glass effect with vibrant borders and semi-transparent backgrounds. |
| Neon | 'neon' |
(Dark Mode Best) Cyberpunk-inspired with glowing neon borders and dark gradients. |
| Minimal | 'minimal' |
Ultra-clean, distraction-free design with simple left-border accents. |
| Neumorphism | 'neumorphism' |
Soft UI design with 3D embossed/debossed plastic-like shadows. |
👉 How to use:
// config/laravel-toaster-magic.php
'theme' => 'neon',
I've rewritten the Javascript core to support Livewire v3 & v4 natively.
Livewire.on (v3) or standard event dispatching.wire:navigate.// Dispatch from component
$this->dispatch('toastMagic',
status: 'success',
message: 'User Saved!',
title: 'Great Job'
);
Want your toasts to pop without changing the entire theme? Enable Gradient Mode to add a subtle "glow-from-within" gradient based on the toast type (Success, Error, etc.).
// config/laravel-toaster-magic.php
'gradient_enable' => true
Works best with Default, Material, Neon, and Glassmorphism themes.
Don't want themes? Just want solid colors? Color Mode forces the background of the toast to match its type (Green for Success, Red for Error, etc.), overriding theme backgrounds for high-visibility alerts.
// config/laravel-toaster-magic.php
'color_mode' => true
I have completely modularized the CSS.
.theme-neon, .theme-ios) to prevent conflicts.body[theme="dark"].Upgrading from v1.x to v2.0?
Update Composer:
composer require devrabiul/laravel-toaster-magic "^2.0"
Check Config: If you have a published config file, add the new options:
'options' => [
'theme' => 'default',
'gradient_enable' => false,
'color_mode' => false,
],
'livewire_version' => 'v3',
v2.0 transforms Laravel Toaster Magic from a simple notification library into a UI-first experience. Whether you're building a sleek SaaS (use iOS), a gaming platform (use Neon), or an admin dashboard (use Material), there is likely a theme for you.
Enjoy the magic! 🍞✨
JavaScript Stability Fixes: Resolved multiple JS-related issues that could cause inconsistent toast behavior in SPA and dynamic page loads. Toasts now render more reliably across Livewire, Alpine.js, and AJAX-driven views.
Improved Event Handling: Fixed edge cases where custom events were not always triggering toast notifications. Event listeners are now more predictable and better scoped.
DOM Ready & SPA Support: Enhanced initialization logic to ensure Toaster Magic works smoothly with page transitions, including Turbo, Inertia, and Livewire navigation.
Performance Tweaks: Reduced unnecessary DOM queries and optimized JS execution flow for faster toast rendering with lower overhead.
Backward Compatibility: Fully compatible with v1.5 and earlier versions — no breaking changes. Existing integrations continue to work without modification.
Documentation Updates: Updated frontend usage examples to reflect the improved JS behavior and best practices.
Version 1.6 focuses on frontend reliability and smoother user experience. With important JavaScript fixes and performance improvements, Toaster Magic now delivers more consistent notifications across modern, dynamic Laravel applications.
Exception Fallback Handling: Added robust exception handling across all toast operations. Now, unexpected errors are gracefully managed without breaking your application. Developers can also provide custom handlers via configuration.
Performance & Optimization: Optimized core toast logic for faster execution. Minified assets and reduced runtime overhead to make the package leaner and more efficient.
PHP & Laravel Compatibility: Fully compatible with PHP 8.0 → 8.4 and Laravel 8 → 12. This ensures smooth integration across modern Laravel projects.
Backward Compatibility: Upgrading from v1.x is seamless. All previous configurations and usages remain supported.
Documentation & Examples: Updated usage examples and configuration instructions for easier integration.
All other configurations remain backward-compatible.
This release focuses on stability, performance, and developer experience. With v1.5, Laravel Toaster Magic is more robust, optimized, and ready for modern Laravel projects.
This release brings exciting visual improvements with Gradient Effects, fixes for Color Mode, and reorganizes the asset directory structure for better maintainability and package publishing.
🌈 New Feature: Gradient Effects
gradient_enable in the config to add smooth gradient backgrounds to all toast notifications.🎨 Fixed Color Mode
color_mode did not apply the correct colors for some toast types (success, error, warning, info).📂 Asset Directory Updates
artisan vendor:publish workflow.🧹 Other Improvements
composer update devrabiul/laravel-toaster-magic
php artisan config:clear
// config/laravel-toaster-magic.php
return [
'options' => [
'gradient_enable' => true,
'color_mode' => true,
// other options...
],
'livewire_enabled' => true,
'livewire_version' => 'v3',
];
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Thanks to all contributors and community members for helping! ❤️
Happy Toasting! 🍞✨
This release introduces a new Color Mode feature that automatically applies toast colors based on toast types, along with important fixes for SPA navigation issues to improve Livewire and frontend routing compatibility.
🎨 New Feature: Color Mode
color_mode in the config to automatically apply distinct colors for toast types (success, error, warning, info).🛠️ Fixed SPA Navigation Issues
🧹 Other Improvements
composer update devrabiul/laravel-toaster-magic
php artisan config:clear
// config/laravel-toaster-magic.php
return [
'options' => [
// other options...
'color_mode' => true,
],
'livewire_enabled' => true,
'livewire_version' => 'v3',
];
Thanks to all community members who helped identify SPA navigation issues and supported the color mode feature development! ❤️
Happy Toasting! 🍞✨
This release focuses on fixing the positionClass config issue and includes other small improvements to enhance your experience with Laravel Toaster Magic.
positionClass
The default positionClass in config/laravel-toaster-magic.php is now correctly set to:'positionClass' => 'toast-bottom-start',
If you’ve not published the config, run:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
✨ Improved Option Merging Logic
Custom options from your config() and runtime calls now merge more reliably.
🧹 Minor Cleanup Small internal cleanups for better code quality.
composer update devrabiul/laravel-toaster-magic
Or,
composer update
php artisan config:clear
Big thanks to [@redredimano](https://github.com/redredimano) for reporting the config issue! ❤️
Happy Toasting! 🍞✨ https://github.com/devrabiul/laravel-toaster-magic
I'm excited to announce v1.1 of Laravel Toaster Magic — a smooth and powerful toast notification package for Laravel and Livewire.
🔥 Material Design Theme
✅ Auto Asset Update Issue Fixed
✅ Livewire JavaScript Compatibility Fixed
wire:navigate and Livewire.on() events.Run:
composer update devrabiul/laravel-toaster-magic
(Optional) Re-publish the assets to get the new Material theme:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Thank you for using Laravel Toaster Magic! ⭐️ Star the repo if you find it useful. Contributions and feedback are always welcome!
Custom Button Support in Livewire Toasts:
You can now include custom buttons in your Livewire-dispatched toasts. Add a link with custom text directly inside the toast notification using the options parameter:
$this->dispatch('toastMagic',
status: 'success',
title: 'User Created',
message: 'The user has been successfully created.',
options: [
'showCloseBtn' => true,
'customBtnText' => 'Link Text',
'customBtnLink' => 'https://demo.com',
],
);
Improved Option Handling: The toast system now gracefully parses and applies advanced configuration options passed from Livewire, offering more control and flexibility.
Better UX with Optional Close Button:
Developers can now toggle a close button per toast using showCloseBtn, offering users manual dismissal options.
Refined Event Handling:
Fine-tuned the way toastMagic events are handled to improve reliability and compatibility across Livewire’s lifecycle events.
Livewire Script Path Issues Resolved: Fixed loading problems with Livewire v3 JavaScript assets to ensure correct path resolution and smooth integration.
Robust Fallbacks for Livewire Scripts: Improved fallback logic for loading core toaster scripts when Livewire assets are unavailable, preventing broken toast notifications.
Full Livewire v3 Support Added:
Seamless integration with Livewire v3 via $this->dispatch('toastMagic', ...) for easy toast notifications directly from Livewire components.
Configurable Livewire Settings:
New configuration options 'livewire_enabled' => true and 'livewire_version' => 'v3' allow developers to toggle and specify Livewire versions with ease.
Enhanced Developer Experience for Livewire Users: Improved asset loading and event dispatching designed to work flawlessly with Livewire’s lifecycle and script management.
A powerful and flexible Toaster package for Laravel applications, designed to enhance user experience with customizable toast notifications.
How can I help you explore Laravel packages today?