### Install package with Composer Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/README.md Installs the package via Composer. This is the first step in the installation process. ```bash composer require devrabiul/laravel-toaster-magic ``` -------------------------------- ### ToastMagic Preset Examples Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/PRESETS.md A comprehensive list of usage examples for various ToastMagic presets, demonstrating how to trigger different animations and configure toast properties like custom buttons and timeouts. ```php use Devrabiul\ToastMagic\Facades\ToastMagic; // 1. Add to cart — bouncing cart ToastMagic::success('Added to cart', 'Nike Air Max ×1', [ 'preset' => 'cart-add', ]); // 1b. Cart updated — quantity arrows fire in opposition ToastMagic::info('Cart updated', 'Quantity changed to 3.', [ 'preset' => 'cart-update', ]); // 1c. Removed from cart — the basket tips out ToastMagic::warning('Removed from cart', 'Apple MacBook Pro M5 removed.', [ 'preset' => 'cart-remove', ]); // 2. Added to wishlist — heart pop + particles ToastMagic::success('Saved to wishlist', 'Nike Air Max', [ 'preset' => 'wishlist-add', ]); // 3. Removed from wishlist — heart flinches, crack draws across ToastMagic::info('Removed from wishlist', 'Nike Air Max', [ 'preset' => 'wishlist-remove', ]); // 4. Order placed — parcel drops in and settles ToastMagic::success('Order placed', 'Order #10482 is confirmed.', [ 'preset' => 'order-placed', 'customBtnText' => 'Track order', 'customBtnLink' => '/orders/10482', ]); // 5. Payment successful — note swipes in, coin pops ToastMagic::success('Payment successful', '€129.00 charged to •••• 4242.', [ 'preset' => 'payment-success', ]); // 6. Payment failed — strike draws across the card, toast shakes ToastMagic::error('Payment failed', 'Your card was declined.', [ 'preset' => 'payment-failed', 'timeOut' => 0, // stays until dismissed — the user must act ]); // 7. Item removed — trash lid lifts ToastMagic::warning('Item removed', 'Nike Air Max ×1 removed from your cart.', [ 'preset' => 'item-removed', ]); // 8. Copied to clipboard — clip snaps onto the board ToastMagic::success('Copied to clipboard', null, [ 'preset' => 'clipboard-copy', 'timeOut' => 2000, ]); // 9. Link shared — share nodes pulse ToastMagic::info('Link shared', 'Anyone with the link can view this.', [ 'preset' => 'link-shared', ]); // 10. Profile updated — head pops, shoulders rise ToastMagic::success('Profile updated', 'Your changes are live.', [ 'preset' => 'profile-updated', ]); // 11. Settings saved — gear turns a full rotation ToastMagic::success('Settings saved', null, [ 'preset' => 'settings-saved', ]); // 12. Download complete — arrow drops into the tray ToastMagic::success('Download complete', 'invoice-10482.pdf', [ 'preset' => 'download-complete', ]); // 13. Upload complete — arrow lifts out of the tray ToastMagic::success('Upload complete', '3 files uploaded.', [ 'preset' => 'upload-complete', ]); // 14. Connection restored — wi-fi signal rebuilds ToastMagic::success('Back online', 'Your connection has been restored.', [ 'preset' => 'connection-restored', ]); // 15. Connection lost — strike draws across the signal ToastMagic::error('You are offline', 'Reconnecting…', [ 'preset' => 'connection-lost', 'timeOut' => 0, // keep it up until the connection is back ]); // 16. Loading — spins until dismissed ToastMagic::info('Generating your report', 'This can take a minute.', [ 'preset' => 'loading', 'timeOut' => 0, // required: the spinner is a progress signal, not a result ]); // 17. Session expiring — hands sweep the clock ToastMagic::warning('Session expiring', 'You will be signed out in 2 minutes.', [ 'preset' => 'session-expiring', 'timeOut' => 0, 'customBtnText' => 'Stay signed in', 'customBtnLink' => '/session/extend', ]); // 18. Out of stock — parcel sags, cross flashes ToastMagic::warning('Out of stock', 'This size is unavailable.', [ 'preset' => 'out-of-stock', ]); // 19. Back in stock — the bell rings ToastMagic::success('Back in stock', 'Apple MacBook Pro M5 is available again.', [ 'preset' => 'back-in-stock', 'customBtnText' => 'View', 'customBtnLink' => '/products/42', ]); // 20. Coupon applied — the ticket is punched ToastMagic::success('Coupon applied', 'SAVE20 — €25.80 off.', [ 'preset' => 'coupon-applied', ]); ``` -------------------------------- ### Install dependencies Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/CONTRIBUTING.md Install the necessary project dependencies using Composer. ```sh composer install ``` -------------------------------- ### Compact Theme with Custom Spacing Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/THEMES.md Example of tuning the compact theme with tighter spacing overrides. ```php 'theme' => 'compact', 'spacing' => [ 'enable' => true, 'container' => '6px 8px', 'icon_gap' => '5px', 'content_gap' => '0px', 'close_gap' => '4px', ], ``` -------------------------------- ### Config Override Example Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/THEMES.md Since v2.5, the published config merges defaults automatically; set only overrides like theme, gradient, and color mode. ```php 'options' => [ 'theme' => 'default', 'gradient_enable' => false, 'color_mode' => false, ], ``` -------------------------------- ### Set theme to neon in config Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/THEMES.md Configure the toaster theme by setting the 'theme' key in the config file. The example uses 'neon', which is described as best for dark mode. ```php // config/laravel-toaster-magic.php 'theme' => 'neon', ``` -------------------------------- ### Tighter spacing configuration Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/README.md Tighter spacing configuration for toasts, using smaller padding and gaps than the default example. ```php 'spacing' => [ 'enable' => true, 'container' => '6px 8px', 'icon_gap' => '5px', 'content_gap' => '0px', 'close_gap' => '4px', ], ``` -------------------------------- ### Enable preset packs Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/release.md Add desired preset packs to the presets array in your configuration file. ```php 'presets' => ['general', 'commerce'], ``` -------------------------------- ### Publish config file Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/README.md Publishes the package configuration file. This step is optional. ```bash php artisan vendor:publish --tag=toast-magic-config ``` -------------------------------- ### Following preset Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/PRESETS.md Triggers a success toast for a follow action. ```php ToastMagic::success('Following', 'You will see their updates.', [ 'preset' => 'follow-added', ]); ``` -------------------------------- ### Clone the repository Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/CONTRIBUTING.md Fork the repository on GitHub and clone it to your local machine to begin development. ```sh git clone https://github.com/your-username/laravel-toaster-magic.git cd laravel-toaster-magic ``` -------------------------------- ### Enable Livewire support in config Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/README.md Enable Livewire support in the config file by setting 'livewire_enabled' to true. ```php // config/laravel-toaster-magic.php return [ 'options' => [ // your toast options... ], 'livewire_enabled' => true, ]; ``` -------------------------------- ### Usage with custom options Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/PRESETS.md Presets can be combined with other existing toast options. ```php ToastMagic::success('Added to cart', 'Nike Air Max ×1', [ 'preset' => 'cart-add', 'showCloseBtn' => true, 'customBtnText' => 'View cart', 'customBtnLink' => '/cart', 'timeOut' => 8000, 'showDuration' => 300, ]); ``` -------------------------------- ### Full Configuration Reference for laravel-toaster-magic Source: https://github.com/devrabiul/laravel-toaster-magic/blob/main/README.md Full configuration reference for the laravel-toaster-magic package. Shows all available options with defaults and comments explaining behavior, including toast appearance, animation, accessibility, spacing, typography, Livewire bridge, CSP nonce, and asset path prefix. ```php // config/laravel-toaster-magic.php return [ 'options' => [ 'escape_html' => true, // Escape toast text. Leave this on. 'closeButton' => true, 'positionClass' => 'toast-top-end', 'preventDuplicates' => false, 'showDuration' => 300, 'timeOut' => 5000, // 0 = stay until dismissed 'stagger' => 800, // Gap between consecutive queued toasts (ms) 'maxVisible' => 15, // Most toasts on screen at once; 0 = no limit 'theme' => 'default', // default, material, ios, glassmorphism, neon, minimal, neumorphism, neumorphic, compact 'gradient_enable' => false, 'color_mode' => false, 'pauseOnHover' => true, // Keyboard focus always pauses the timer 'animation' => 'default', // default, slide, fade, pop, bounce // Accessible names 'closeButtonLabel' => 'Close notification', 'containerLabel' => 'Notifications', // Global spacing — 'enable' => false uses each theme's own spacing. 'spacing' => [ 'enable' => true, 'container' => '10px 12px', 'icon_gap' => '8px', 'content_gap' => '2px', 'close_gap' => '6px', ], // Global typography — 'enable' => false uses each theme's own typography. // 'title_weight', 'description_weight' and 'line_height' are optional. 'typography' => [ 'enable' => true, 'title_size' => '14px', 'description_size' => '13px', ], ], // One event bridge serves both Livewire v3 and v4. 'livewire_enabled' => false, // CSP nonce for the inline