Loading Alert
Show a non-dismissable spinner while a long-running action is in flight. Pair with close() to dismiss it once done.
asLoading()
Locks the alert (no buttons, ESC + backdrop click ignored) and triggers Swal.showLoading() on open via the didOpen callback.
Live demo
SweetAlert2
PHP
LivewireAlert
public function save(): void
{
LivewireAlert::title('Saving...')
->asLoading()
->show();
// long-running work here
$this->persist();
LivewireAlert::close();
}
Custom title
Pass a string to override the default 'Loading...' title.
Live demo
SweetAlert2
PHP
LivewireAlert
LivewireAlert::asLoading('Uploading file...')->show();
Full lifecycle
Open, do work, close, then toast on completion. Handler runs server-side so the spinner stays up until the request returns.
Live demo
SweetAlert2
PHP
LivewireAlert
public function process(): void
{
LivewireAlert::title('Processing...')
->asLoading()
->show();
sleep(2); // your long-running work
LivewireAlert::close();
LivewireAlert::title('Done!')
->success()
->asToast()
->show();
}
Next: Updating an open alert →