Skip to content

marcorombach/livewire-confirm-modal

Repository files navigation

Livewire Confirm-Modal

Latest Version on Packagist Total Downloads

This is a simple package aiming to provide a Livewire directive like wire:confirm but without using the default javascript confirm() function. This is useful if you need the same style for the confirm box across different browsers. It's also possible to apply your own style by changing the view.

By default this package uses TailwindCSS to style the modal. The look of the modal was inspired by the components of Pines UI.

alt text

Installation

You can install the package via composer:

composer require marcorombach/livewire-confirm-modal

You need to add the following to your tailwind.config.js

"./vendor/marcorombach/livewire-confirm-modal/resources/views/components/*.php"

It should look something like this:

content: [
    "./resources/**/*.blade.php",
    "./resources/**/*.js",
    ...
    "./vendor/marcorombach/livewire-confirm-modal/resources/views/components/*.php",
] 

To include the necessary scripts and the modal itself, make sure this is present in all your views that should use wire:confirm-modal

<x-livewire-confirm-modal/>

Optionally, you can publish the view using

php artisan vendor:publish --tag="livewire-confirm-modal-views"

You should be careful changing the view, especially when touching alpine directives.

Usage

<button wire:confirm-modal="title|description" wire:click="doSomething(1,2)">
    Test
</button>

Replace title and description with what you want the confirm modal to display. Now a modal is shown everytime the button is clicked. It will prevent wire:click from executing until the continue button in the modal is clicked.

Credits

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published