Core Pattern
Timers
Timers automatically dismiss alerts after a fixed duration. They are useful for success states and passive messages.
Timer
Pass milliseconds to timer(). Try a custom duration below; the demo accepts 500ms to 15000ms.
Live demo
SweetAlert2
Current duration: 3000ms / 3s
PHP
LivewireAlert
public string $timerMilliseconds = '3000';
public function fireTimer(): void
{
$duration = (int) $this->timerMilliseconds;
LivewireAlert::title('Success')
->text("This alert closes after {$duration}ms.")
->success()
->timer($duration)
->show();
}
Static timer
For fixed durations, pass the number directly. SweetAlert2 expects milliseconds, so 3000 means 3 seconds.
PHP
LivewireAlert
LivewireAlert::title('Success')
->text('Operation completed successfully.')
->success()
->timer(3000)
->show();
Timer progress bar
Use timerProgressBar() to show the countdown visually. This demo uses the same custom duration from above.
Live demo
SweetAlert2
PHP
LivewireAlert
LivewireAlert::title('Success')
->text("Progress bar duration: {$duration}ms.")
->success()
->timer($duration)
->timerProgressBar()
->show();
Disable the timer
Use timer(null) for alerts that require explicit user action.
Live demo
SweetAlert2
PHP
LivewireAlert
LivewireAlert::title('Review required')
->warning()
->timer(null)
->withConfirmButton('Got it')
->show();