百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

livewire-alert

> 后端框架
开源

SweetAlert2 与 Livewire 的集成

806 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

SweetAlert2 与 Livewire 的集成

Livewire Alert

Livewire Alert is a Laravel Livewire package that brings SweetAlert2 notifications to your Livewire components through a fluent, chainable API. Configure and trigger beautiful, interactive alerts with a clean PHP interface — no JavaScript required.

Documentation

Full documentation, live examples, and an interactive playground are hosted at:

https://livewire-alert.jantinnerezo.me

Every feature — icons, positions, toasts, timers, buttons, confirm dialogs, loading alerts, in-place updates, inputs, flash alerts, images, custom classes, dependency injection and more — is documented there with copy-pasteable snippets and runnable demos.

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x or higher
  • Livewire 3.x or 4.x
  • Composer

Installation

Require the package with Composer:

composer require jantinnerezo/livewire-alert

Optionally publish the config file:

php artisan vendor:publish --tag=livewire-alert:config

Install SweetAlert2 via npm or yarn:

npm install sweetalert2
yarn add sweetalert2

Then import it in resources/js/app.js:

import Swal from 'sweetalert2'

window.Swal = Swal

Or include it via CDN before the closing `` tag:

Filament

Register SweetAlert2 as a Filament asset in your AppServiceProvider:

use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\Facades\Vite;
use Filament\Support\Assets\Js;

public function boot()
{
    FilamentAsset::register([
        Js::make('sweetalert2', Vite::asset('resources/js/sweetalert2.js')),
        // Or via CDN:
        // Js::make('sweetalert2', 'https://cdn.jsdelivr.net/npm/sweetalert2@11'),
    ]);
}

Quick taste

use Jantinnerezo\LivewireAlert\Facades\LivewireAlert;

public function save()
{
    LivewireAlert::title('Changes saved!')
        ->success()
        ->show();
}

For everything else — head to the documentation site.

Looking for v3?

The last v3 release was v3.0.3 (March 11, 2024). v4 is a major refactor introducing the fluent Facade API, dependency injection, and many more features. For v3:

composer require jantinnerezo/livewire-alert:^3.0

Upgrading to v4 is recommended for new and ongoing projects.

Testing

composer test

Contributors

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPalpinejslaravellivewiresweetalert2

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架