PHPackages                             matierenoire/laravel-livewire-swal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. matierenoire/laravel-livewire-swal

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

matierenoire/laravel-livewire-swal
==================================

This package provides a simple alert utilities for your livewire components.

45.8kPHP

Since Sep 11Pushed 1y agoCompare

[ Source](https://github.com/matiere-noire/laravel-livewire-swal)[ Packagist](https://packagist.org/packages/matierenoire/laravel-livewire-swal)[ RSS](/packages/matierenoire-laravel-livewire-swal/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Livewire Swal
=====================

[](#laravel-livewire-swal)

Directly inspired by :

🚀 Installation
==============

[](#rocket-installation)

You can install the package via composer:

```
composer require matierenoire/laravel-livewire-swal
```

Requirements
============

[](#requirements)

This package uses Livewire under the hood. Please make sure you include it in your dependencies before using this package.

- PHP 7.2 or higher
- Laravel 7, 8, 9, 10, 11
- Livewire
- SweetAlert2

Usage
=====

[](#usage)

Include Component
-----------------

[](#include-component)

Insert Sweet2Alert2 and livewire alert scripts component after livewire scripts directive.

SweetAlert2 script is not included by default so make sure you include it before

```

  ... @livewireScripts ...

  ...

```

Publish Config File
-------------------

[](#publish-config-file)

```
php artisan vendor:publish --provider="MN\LivewireAlert\LivewireAlertServiceProvider" --tag="config"
```

Show Alert
----------

[](#show-alert)

You can play around with SweetAlert2 configuration.

```
$this->alert('success', 'Hello World!', [
      'position' =>  'top-end',
      'timer' =>  3000,
      'toast' =>  true,
      'text' =>  '',
      'confirmButtonText' =>  'Ok',
      'cancelButtonText' =>  'Cancel',
      'showCancelButton' =>  true,
      'showConfirmButton' =>  false,
]);
```

Alert Confirmation
------------------

[](#alert-confirmation)

This package also supports showing confirmation alert on action.

This is a complete refactor of the previous alert confirmation to support multiple confirms on the same livewire component. First, setup your action methods for onConfirmed and onCancelled callback. Of course you can name your methods anything you want.

```
public function confirmed()
{
    // Example code inside confirmed callback

    $this->alert(
        'success',
        'Thanks! consider giving it a star on github.'
    );
}

public function cancelled()
{
    // Example code inside cancelled callback

    $this->alert('info', 'Understood');
}
```

Make sure you register confirmed and cancelled methods as event listeners.

See: laravel-livewire.com/docs/2.x/events for more information about event listeners.

If you have multiple confirmation alerts on the same livewire component, you can define as many callback methods you want and just add it to event listeners.

```
protected $listeners = [
    'confirmed',
    'cancelled',
    ...
];
```

Finally, create an action method that triggers the confirmation alert with onConfirmed and onCancelled callbacks pointed to the event listeners you registered.

```
public function triggerConfirm()
{
    $this->confirm('Do you love Livewire Alert?', [
        'toast' => false,
        'position' => 'center',
        'showConfirmButton' => true,
        'cancelButtonText' => Nope,
        'onConfirmed' => 'confirmed',
        // 'onConfirmed' => ['confirmed', $id], you can pass argument with array
        'onCancelled' => 'cancelled'
    ];
}
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a40a04114ebd7bc941bb65f17661eefe26b4e07e38918c41c774e69f368591d?d=identicon)[MatiereNoire](/maintainers/MatiereNoire)

### Embed Badge

![Health badge](/badges/matierenoire-laravel-livewire-swal/health.svg)

```
[![Health](https://phpackages.com/badges/matierenoire-laravel-livewire-swal/health.svg)](https://phpackages.com/packages/matierenoire-laravel-livewire-swal)
```

###  Alternatives

[alexis-magina/cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others. Search with Ajax.

3913.4k1](/packages/alexis-magina-cmb2-field-post-search-ajax)[robloach/jquery-once

Act on jQuery elements only once.

602.1k](/packages/robloach-jquery-once)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
