rayhan-bapari / notyfyre
A modern, beautiful and highly customizable toast notification system for Laravel applications with extensive JavaScript API
Installs: 38
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Language:JavaScript
Requires
- php: ^8.0|^8.1|^8.2|^8.3|^8.4
- illuminate/session: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
- illuminate/view: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5|^10.0|^11.0
README
A modern, beautiful, and highly customizable toast notification system for Laravel applications. Features both powerful Laravel backend integration and a comprehensive JavaScript API for maximum flexibility.
β¨ Features
- π¨ 40+ Beautiful Themes - From minimal to neon, glassmorphism to retro
- π Modern JavaScript API - ES6+ with full customization
- π« Smooth Animations - Multiple animation types (slide, fade, bounce)
- π± Fully Responsive - Mobile-first design
- βΏ Accessibility Ready - ARIA labels, keyboard navigation
- ποΈ Highly Configurable - Every aspect can be customized
- π¦ Laravel Integration - Seamless backend/frontend workflow
- π Queue Management - Smart notification queuing
- βΈοΈ Pause/Resume - Hover and focus loss handling
- π― Action Buttons - Add interactive buttons to notifications
- πͺ Progress Bars - Visual countdown indicators
- π XSS Protection - Built-in HTML escaping
- π 7 Positions - Place notifications anywhere on screen
π Quick Start
Installation
composer require rayhan-bapari/notyfyre
Publish Assets
php artisan vendor:publish --tag=notyfyre
Basic Setup
1. In your layout (e.g., app.blade.php
):
<!DOCTYPE html> <html> <head> @notyfyreStyles </head> <body> <!-- Your content --> @notyfyreScripts @notyfyreRender </body> </html>
2. In your controller:
use RayhanBapari\Notyfyre\Facades\Notyfyre; class UserController extends Controller { public function store() { // Your logic here... Notyfyre::success('User created successfully!')->flash(); return redirect()->back(); } }
3. In your JavaScript:
// Show notifications directly notify.success('Hello World!'); notify.error('Something went wrong!'); notify.warning('Please check your input'); notify.info('Information message'); // With options notify.success('Success message', { duration: 7000, position: 'top-center', theme: 'glassmorphism', actions: [ { text: 'Undo', callback: () => console.log('Undo clicked!') } ] });
π Documentation
Laravel Backend Usage
Basic Methods
// Simple notifications Notyfyre::success('Operation completed!')->flash(); Notyfyre::error('Something went wrong!')->flash(); Notyfyre::warning('Please check your input')->flash(); Notyfyre::info('New updates available')->flash(); // Show immediately (current request) Notyfyre::success('Saved!')->now();
Advanced Configuration
Notyfyre::success('User created successfully!') ->title('Success!') ->position('top-center') ->duration(7000) ->theme('material') ->icon('<i class="fas fa-check"></i>') ->progress(true) ->pauseOnHover(true) ->actions([ [ 'text' => 'View', 'callback' => 'window.location.href = "/users"' ], [ 'text' => 'Undo', 'callback' => 'undoUserCreation()' ] ]) ->flash();
Method Chaining
Notyfyre::custom() ->message('Custom notification') ->type('success') ->position('bottom-right') ->duration(5000) ->theme('neon') ->closable(true) ->progress(true) ->pauseOnHover(true) ->pauseOnFocusLoss(true) ->preventDuplicates(true) ->escapeHtml(true) ->closeOnClick(false) ->progressColor('#ff6b6b') ->animation('bounce', 400) ->onShow('console.log("Notification shown")') ->onClose('console.log("Notification closed")') ->onClick('console.log("Notification clicked")') ->flash();
JavaScript API
Basic Usage
// Simple notifications notify.success('Success message'); notify.error('Error message'); notify.warning('Warning message'); notify.info('Info message'); // Custom notification notify.custom({ message: 'Custom message', type: 'success', duration: 5000 });
Advanced Options
notify.success('Order processed successfully!', { title: 'Order Complete', position: 'top-center', duration: 7000, theme: 'glassmorphism', closable: true, progress: true, progressColor: '#10b981', pauseOnHover: true, pauseOnFocusLoss: true, preventDuplicates: true, closeOnClick: false, animation: { type: 'bounce', duration: 400 }, actions: [ { text: 'View Order', callback: (element, notifier) => { window.location.href = '/orders/123'; } }, { text: 'Continue Shopping', callback: () => { console.log('Continue shopping clicked'); }, close: false // Don't close notification after click } ], onShow: (element, notifier) => { console.log('Notification shown'); }, onClose: (element, notifier) => { console.log('Notification closed'); }, onClick: (element, notifier) => { console.log('Notification clicked'); } });
Management Methods
// Get notification ID for later reference const id = notify.success('Message'); // Update existing notification notify.update(id, { message: 'Updated message', type: 'warning' }); // Remove specific notification notify.remove(id); // Clear all notifications notify.clearAll(); // Clear notifications by position notify.clearByPosition('top-right'); // Pause/resume specific notification notify.pause(id); notify.resume(id); // Pause/resume all notifications notify.pauseAll(); notify.resumeAll(); // Get active notifications const active = notify.getActive(); // Get queue length const queueLength = notify.getQueueLength('top-right'); // Configure global defaults notify.configure({ duration: 6000, theme: 'dark', position: 'bottom-center' });
π¨ Themes
Choose from 40+ built-in themes:
Basic Themes:
default
- Clean and simpleminimal
- Subtle and understateddark
- Dark mode friendlylight
- Bright and airy
Modern Themes:
glassmorphism
- Frosted glass effectneumorphism
- Soft 3D appearancematerial
- Google Material Designgradient
- Beautiful gradients
Special Effects:
neon
- Glowing neon effectsholographic
- Iridescent colorsaurora
- Northern lights inspiredcyberpunk
- Futuristic sci-fi
Creative Themes:
retro
- Vintage 80s stylecomic
- Comic book aestheticpixel
- 8-bit pixel arthandwritten
- Casual handwritten look
Professional Themes:
corporate
- Business-appropriateelegant
- Sophisticated serifzen
- Calm and peacefulnordic
- Scandinavian minimalism
And many more! See the full list in the Theme Gallery.
π§ Configuration
Laravel Configuration
Publish and edit the config file:
php artisan vendor:publish --tag=notyfyre-config
// config/notyfyre.php return [ 'defaults' => [ 'position' => 'top-right', 'duration' => 5000, 'theme' => 'default', 'maxVisible' => 5, // ... more options ], 'themes' => [ 'default', 'minimal', 'dark', 'glassmorphism', // ... all available themes ], 'assets' => [ 'auto_inject' => false, 'cdn' => [ 'enabled' => false, 'css_url' => '...', 'js_url' => '...' ] ] ];
JavaScript Configuration
// Configure global defaults notify.configure({ position: 'bottom-right', duration: 6000, theme: 'dark', maxVisible: 3, preventDuplicates: true, animation: { type: 'slide', duration: 300 } });
π Positions
Available positions:
top-left
top-center
top-right
center
bottom-left
bottom-center
bottom-right
π Animations
Animation types:
slide
- Slide in/out (default)fade
- Fade in/outbounce
- Bounce effect
πͺ Action Buttons
Add interactive buttons to notifications:
Laravel:
Notyfyre::success('File uploaded!') ->actions([ [ 'text' => 'View', 'callback' => 'window.open("/files/123")' ], [ 'text' => 'Share', 'callback' => 'shareFile(123)' ] ]) ->flash();
JavaScript:
notify.info('New message received', { actions: [ { text: 'Read', callback: (element, notifier) => { window.location.href = '/messages/new'; } }, { text: 'Mark as Read', callback: () => { markAsRead(); }, close: false // Keep notification open } ] });
βΏ Accessibility
Notyfyre is built with accessibility in mind:
- ARIA Labels - Proper screen reader support
- Keyboard Navigation - Tab through interactive elements
- High Contrast - Supports high contrast mode
- Reduced Motion - Respects
prefers-reduced-motion
- Focus Management - Proper focus handling
π± Responsive Design
- Mobile First - Optimized for mobile devices
- Breakpoint Responsive - Adapts to different screen sizes
- Touch Friendly - Proper touch targets
- Safe Areas - Respects device safe areas
π Security
- XSS Protection - HTML escaping by default
- Content Security Policy - CSP compatible
- Input Sanitization - Safe handling of user input
π§ͺ Browser Support
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- iOS Safari 12+
- Chrome Android 60+
π Advanced Examples
Laravel Examples
Form Validation:
public function store(Request $request) { $validator = Validator::make($request->all(), [ 'email' => 'required|email|unique:users' ]); if ($validator->fails()) { Notyfyre::error('Please check your input') ->title('Validation Error') ->theme('material') ->flash(); return back()->withErrors($validator); } // Create user... Notyfyre::success('Welcome! Your account has been created.') ->title('Account Created') ->duration(8000) ->theme('gradient') ->actions([ [ 'text' => 'Complete Profile', 'callback' => 'window.location.href = "/profile/edit"' ] ]) ->flash(); return redirect('/dashboard'); }
File Upload Progress:
public function uploadFile(Request $request) { // Upload logic... Notyfyre::success('File uploaded successfully!') ->title('Upload Complete') ->theme('glassmorphism') ->progress(true) ->actions([ [ 'text' => 'View File', 'callback' => "window.open('/files/{$file->id}')" ], [ 'text' => 'Share', 'callback' => "shareFile({$file->id})" ] ]) ->flash(); }
JavaScript Examples
Real-time Notifications:
// WebSocket or Server-Sent Events socket.on('notification', function(data) { notify[data.type](data.message, { title: data.title, theme: 'aurora', duration: data.duration || 5000, actions: data.actions || [] }); }); // API Success/Error Handling fetch('/api/data') .then(response => response.json()) .then(data => { notify.success('Data loaded successfully!', { theme: 'material', duration: 3000 }); }) .catch(error => { notify.error('Failed to load data', { title: 'Network Error', theme: 'neon', actions: [ { text: 'Retry', callback: () => location.reload() } ] }); });
Progress Tracking:
// Simulate progress function uploadFile() { const id = notify.info('Uploading file...', { duration: 0, // Don't auto-close progress: false, theme: 'minimal' }); let progress = 0; const interval = setInterval(() => { progress += 10; notify.update(id, { message: `Uploading file... ${progress}%` }); if (progress >= 100) { clearInterval(interval); notify.update(id, { message: 'File uploaded successfully!', type: 'success', duration: 3000 }); } }, 200); }
Shopping Cart Example:
function addToCart(productId) { // Add to cart logic... notify.success('Product added to cart!', { theme: 'bubble', duration: 4000, actions: [ { text: 'View Cart', callback: () => { window.location.href = '/cart'; } }, { text: 'Continue Shopping', callback: () => { // Do nothing, just close } } ] }); }
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Inspired by modern notification libraries
- Built with β€οΈ for the Laravel community
- Icons by Lucide
π Support
- π§ Email: mdrayhanbapari02@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
Made with β€οΈ by Rayhan Bapari