Dynamic Laravel Livewire 3 Tailwind modals.
kezeneilhou/livewire-tailwind-modal is a Laravel package for dynamic laravel livewire 3 tailwind modals..
It currently has 0 GitHub stars and 951 downloads on Packagist (latest version v2.0.9).
Install it with composer require kezeneilhou/livewire-tailwind-modal.
Discover more Laravel packages by kezeneilhou
or browse all Laravel packages to compare alternatives.
Last updated
# Laravel Livewire Tailwind Modals
A dynamic global modal component for **Laravel 12** and **Livewire 4**, built to work seamlessly with **Livewire Flux**.
This package allows you to load any Livewire component inside a single reusable modal, without polluting your DOM with multiple modal instances.
---
## π Requirements
PHP 8.2+
Laravel 12+
Livewire 4+
Livewire Flux (must be installed and configured)
---
## π¦ Installation
Install the package via Composer:
```bash
composer require kezeneilhou/livewire-tailwind-modal
Publish the JavaScript and view files:
php artisan vendor:publish --tag=livewire-tailwind-modal:assets
php artisan vendor:publish --tag=livewire-tailwind-modal:views
Import the modal script into your main app.js file:
// resources/js/app.js
import './vendor/livewire-tailwind-modal/modals.js';
Then rebuild assets:
npm run dev
Add the <livewire:modals /> component to your main layout (for example: layouts/app.blade.php).
Place it near the end of the <body> tag.
Make sure @fluxScripts and @livewireScripts are included.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@fluxStyles
</head>
<body class="min-h-screen bg-white dark:bg-zinc-800">
{{ $slot }}
<!-- Global Modal -->
<livewire:modals />
@fluxScripts
@livewireScripts
</body>
</html>
You can trigger a modal from a normal Blade view or JavaScript using Livewire.dispatch.
<button
type="button"
onclick="Livewire.dispatch('showModal', {
data: { alias: 'modals.example' }
})"
>
Open Modal
</button>
<div>
<button
type="button"
wire:click="$dispatch('showModal', {
data: { alias: 'modals.example' }
})"
>
Open Modal
</button>
</div>
You may pass parameters, size, and title when opening a modal.
| Value | Width |
| ------------ | ------------------ |
| 1 or sm | Small |
| 2 or md | Medium (default) |
| 3 or lg | Large |
| 4 or xl | Extra Large |
| 5 or 2xl | 2XL |
| 6 or 3xl | 3XL |
| 4xl-7xl | Larger widths |
| full | Viewport width cap |
The modal width is responsive and capped to the viewport, so large sizes still fit on small screens.
<div>
<button
type="button"
wire:click="$dispatch('showModal', {
data: {
alias: 'modals.example',
params: { name: 'test' },
size: '4',
title: 'Test Modal'
}
})"
>
Open Modal
</button>
</div>
namespace App\Http\Livewire\Users;
use Livewire\Component;
class Update extends Component
{
public function mount($name)
{
// $name = "test"
}
public function render()
{
return view('users.update');
}
}
<button type="button" wire:click="$dispatch('hideModal')">
Close
</button>
public function save()
{
$this->validate();
// Save logic...
$this->dispatch('hideModal');
}
If you want to customize the modal layout or animations, publish the package view:
php artisan vendor:publish --tag=livewire-tailwind-modal:views
The view will be copied to:
resources/views/vendor/livewire-tailwind-modal
You may edit it freely. The package will automatically use your customized view.
Make sure:
modals.js is imported in app.jsnpm run build has been executedEnsure Alpine is loaded before modals.js:
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
import './vendor/livewire-tailwind-modal/modals.js';