PHP code example of rifrocket / filament-alert-box
1. Go to this page and download the library: Download rifrocket/filament-alert-box library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rifrocket / filament-alert-box example snippets
use RifRocket\FilamentAlertBox\AlertBoxPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
AlertBoxPlugin::make(),
]);
}
use RifRocket\FilamentAlertBox\Facades\AlertBox;
// Simple success alert
AlertBox::make('Operation Successful')
->success()
->show();
// Error alert with description
AlertBox::make('Error Occurred')
->message('Something went wrong while processing your request.')
->danger()
->permanent()
->show();
// Style 1: Simple Banner (default)
AlertBox::make('Welcome')->success()->bannerStyle()->show();
// Style 2: Card with Border
AlertBox::make('Information')->info()->cardWithBorder()->show();
// Style 3: Modern Card
AlertBox::make('Warning')->warning()->modernCard()->show();
// Style 4: Minimalist
AlertBox::make('Update Available')->info()->minimalistStyle()->show();
// Or use the generic method
AlertBox::make('Custom')->success()->cardStyle(2)->show();
// Modern card in header position
AlertBox::make('Welcome')->success()->modernCard()->pageHeaderAfter()->show();
// Minimalist style in topbar
AlertBox::make('Quick Notice')->info()->minimalistStyle()->topBarStart()->show();
// Bordered card at page end
AlertBox::make('Done!')->success()->cardWithBorder()->pageEnd()->show();
// Success alerts
AlertBox::make('Success!')->success()->show();
// Error/Danger alerts
AlertBox::make('Error!')->danger()->show();
AlertBox::make('Error!')->error()->show(); // Alias for danger
// Warning alerts
AlertBox::make('Warning!')->warning()->show();
// Info alerts (default)
AlertBox::make('Information')->info()->show();
AlertBox::make('Custom Alert')
->message('This is the main message')
->description('Additional description text')
->icon('heroicon-o-check-circle')
->iconColor('#10b981')
->titleColor('#059669')
->success()
->modernCard() // Use modern card style
->pageHeaderAfter() // Position in header
->canBeClose(true)
->autoDisappear(10) // Auto-hide after 10 seconds
->classes('custom-alert-class')
->style('border: 2px solid red;')
->show();
// Auto-hide after 5 seconds
AlertBox::make('Auto Hide')
->success()
->autoDisappear(5)
->show();
// Permanent alert (user must close)
AlertBox::make('Important Notice')
->warning()
->permanent()
->show();
// Closeable control
AlertBox::make('Closeable Alert')
->info()
->canBeClose(false) // Cannot be closed by user
->show();
// Quick success alert
AlertBox::success('Operation completed successfully!')->show();
// Quick error alert
AlertBox::error('Something went wrong!')->show();
// Quick warning alert
AlertBox::warning('Please check your input.')->show();
// Quick info alert
AlertBox::info('Here is some information.')->show();
// Chain additional methods with quick methods
AlertBox::success('Data saved!')
->modernCard()
->autoDisappear(5)
->pageHeaderAfter()
->show();
use RifRocket\FilamentAlertBox\AlertBoxManager;
// Get alerts for position
$alerts = AlertBoxManager::getAlerts('position');
// Clear alerts for position
AlertBoxManager::clearAlerts('position');
// Clear all alerts
AlertBoxManager::clearAll();
// Get alert count
$count = AlertBoxManager::getAlertCount();
AlertBox::make('Custom Icon')
->icon('heroicon-o-star')
->iconSize('lg') // or ->iconLG()
->success()
->show();
// Extra Small (3x3)
AlertBox::make('Minimal Alert')->iconXS()->info()->show();
// Small (4x4)
AlertBox::make('Small Alert')->iconS()->warning()->show();
// Medium (6x6) - Default
AlertBox::make('Normal Alert')->iconM()->success()->show();
// Large (8x8)
AlertBox::make('Important Alert')->iconLG()->danger()->show();
// Extra Large (10x10)
AlertBox::make('Critical Alert')->iconXL()->error()->show();