PHPackages                             akhaled/livewire-sweetalert - 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. akhaled/livewire-sweetalert

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

akhaled/livewire-sweetalert
===========================

Integration Sweetalert with Livewire

v0.2.3(1y ago)182.1k14MITPHP

Since Nov 13Pushed 1y ago2 watchersCompare

[ Source](https://github.com/akhled/livewire-sweetalert)[ Packagist](https://packagist.org/packages/akhaled/livewire-sweetalert)[ RSS](/packages/akhaled-livewire-sweetalert/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (2)Versions (13)Used By (4)

Livewire Sweetalert
====================

[](#livewire-sweetalert-)

Integrate livewire with [Sweetalert](https://sweetalert2.github.io/).

- [Installation](#installation)
- [How to use](#how-to-use)
- [Toast](#toast)
- [Fire](#fire)
- [Confirm](#confirm)
    - [Multiple confirmation component](#multiple-confirmation-component)
    - [Using PHP 8 Attribute](#using-php-8-attribute)
    - [Passing event data](#passing-event-data)
- [Available configuration](#available-configuration)

[Installation](https://packagist.org/packages/akhaled/livewire-sweetalert)
--------------------------------------------------------------------------

[](#installation)

`composer require akhaled/livewire-sweetalert`

How to use
----------

[](#how-to-use)

### 1. Include javascript

[](#1-include-javascript)

```
    ...

    @livewireScripts
    @livewireSweetalertScripts

```

### 2. Extra config file

[](#2-extra-config-file)

Publish the configs: `php artisan vendor:publish --tag=livewire-sweetalert-config`.

> See [available configuration](#available-configuration)

---

Toast
-----

[](#toast)

In your component add `Toast` trait. Then call `toast` method whenever you want.

```
use Akhaled\LivewireSweetalert\Toast;
use Livewire\Component;

class MyComponent extends Component
{
    use Toast;

    public function save() {
        $this->toast('Toast message', 'success', 5000);
    }
    ...
}
```

**toast parameters:**

- title
- [icon](https://sweetalert2.github.io/#icons): success, error, warning, info, question - default is **info**
- timeout: in milliseconds, default is 5000

---

Fire
----

[](#fire)

This is the normal sweetalert [modal](https://sweetalert2.github.io/#examples). In your component add `Fire` trait. Then call `fire` method whenever you want.

```
use Akhaled\LivewireSweetalert\Fire;
use Livewire\Component;

class MyComponent extends Component
{
    use Fire;

    public function save() {
        $options = [];
        $this->Fire('Error happened', 'error', 'please try again later', $options);
    }
    ...
}
```

**fire parameters:**

- titleText: The title of the popup, as text to avoid HTML injection.
- [icon](https://sweetalert2.github.io/#icons): success, error, warning, info, question - default is **info**.
- html: the html which is displayed under the title.
- options: [all options](https://sweetalert2.github.io/#configuration) that sweetalert provides.

---

Confirm
-------

[](#confirm)

Add `Confirm` trait to your component. Then call `confirm` method whenever you want. On confirmation, `confirmed` event is being emitted. Add it to `$listeners` property in you component. See example:

```
use Akhaled\LivewireSweetalert\Confirm;
use Livewire\Component;

class MyComponent extends Component
{
    use Confirm;

    protected $listeners = [
        'confirmed' => 'onConfirmation'
    ];

    public function delete()
    {
        $options = []; // default ['event' => 'confirmed']
        $this->confirm('Are you sure you want to delete', 'you can\'t revert that', $options);
    }

    public function onConfirmation()
    {
        dd('confirmed!');
    }
}
```

**confirm parameters:**

- title: The title of the popup, as text to avoid HTML injection.
- html: the html which is displayed under the title.
- options: [all options](https://sweetalert2.github.io/#configuration) that sweetalert provides. *In addition to event key for using multiple confirmation on same component. see following example*

### Multiple confirmation component

[](#multiple-confirmation-component)

```
use Akhaled\LivewireSweetalert\Confirm;
use Livewire\Component;

class MyComponent extends Component
{
    use Confirm;

    protected $listeners = [
        'confirmed' => 'onConfirmation',
        'anotherConfirmed' => 'onAnotherConfirmation'
    ];

    public function delete()
    {
        $options = []; // default ['event' => 'confirmed']
        $this->confirm('Are you sure you want to delete', 'you can\'t revert that', $options);
    }

    public function onConfirmation()
    {
        dd('confirmed!');
    }

    public function anotherAction()
    {
        $options = [
            'event' => 'anotherConfirmed'; //  'phpOnAttribute';
        ];
        $this->confirm('Are you sure you want to delete', 'you can\'t revert that', $options)
    }

    #[On('phpOnAttribute')]
    public function onConfirmationWithAttribute()
    {
        dd('confirmed #3!');
    }
}
```

### Passing event data

[](#passing-event-data)

```
use Akhaled\LivewireSweetalert\Confirm;
use Livewire\Component;
use Livewire\Attributes\On;

class MyComponent extends Component
{
    use Confirm;

    public function save()
    {
        $this->confirm(
            event: 'savedConfirmed',
            data: [
                'key' => 'value',
            ]
        )
    }

    #[On('savedConfirmed')]
    public function onSavedConfirmations(array $data)
    {
        dd($data['key']); // value
    }
}
```

---

Available configuration
-----------------------

[](#available-configuration)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~136 days

Recently: every ~273 days

Total

11

Last Release

698d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b287abe0508bd1591fc87a4d0b770a9545fe6033e9be97f1fcab4d5ec78753c6?d=identicon)[akhaled](/maintainers/akhaled)

---

Top Contributors

[![amrography](https://avatars.githubusercontent.com/u/9614340?v=4)](https://github.com/amrography "amrography (11 commits)")

### Embed Badge

![Health badge](/badges/akhaled-livewire-sweetalert/health.svg)

```
[![Health](https://phpackages.com/badges/akhaled-livewire-sweetalert/health.svg)](https://phpackages.com/packages/akhaled-livewire-sweetalert)
```

###  Alternatives

[livewire/flux

The official UI component library for Livewire.

9527.8M128](/packages/livewire-flux)[jantinnerezo/livewire-alert

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

8131.4M20](/packages/jantinnerezo-livewire-alert)[leandrocfe/filament-apex-charts

Apex Charts integration for Filament PHP.

4911.6M11](/packages/leandrocfe-filament-apex-charts)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725172.4k14](/packages/tallstackui-tallstackui)[venturedrake/laravel-crm

A free open source CRM built as a package for laravel projects

43311.1k](/packages/venturedrake-laravel-crm)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21259.6k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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