Download the PHP package elegantly/livewire-modal without Composer
On this page you can find all versions of the php package elegantly/livewire-modal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elegantly/livewire-modal
More information about elegantly/livewire-modal
Files in elegantly/livewire-modal
Package livewire-modal
Short Description Modal for your Livewire App. Done right.
License MIT
Homepage https://github.com/ElegantEngineeringTech/livewire-modal
Informations about the package livewire-modal
Livewire Modals. Done Right.
This package allows you to seamlessly open Livewire components inside modals or slideovers with powerful features:
- Support for modals, slideovers, and similar UI patterns.
- Nested and stacked modals.
- Custom styling and animations, with optional presets.
- Preloading components for faster interactions.
Requirements
livewire/livewire: v4tailwindcss: v3 (not yet tested with v4)
How It Works
This package provides a single Livewire Modal component that should be placed at the end of your body tag. This component dynamically renders and manages all modal instances while maintaining a modal history.
Modals can be opened and closed by dispatching modal-open and modal-close events.
For security, only components you explicitly allow can be opened in a modal (see Allowing Components).
Installation
Install the package via Composer:
To customize modal behavior, publish the views with:
Usage
Configuring Tailwind CSS
Since the modal component is styled using Tailwind CSS, you must include its views in your Tailwind configuration file:
Setting Up Your Application
Add the modal manager component <livewire:modal /> at the end of your body tag, typically in your layout views:
Allowing Components
The list of opened modals is sent by the browser, so anyone can ask the modal manager to render any component with any props. To prevent this, the modal manager refuses (403) every component that has not been explicitly allowed.
Allow a component by implementing the ModalComponent contract:
To allow components you can't modify (from a vendor package for example), publish the config file and list them by name or class:
Props must be passed by name ({ userId: 1 }); positional props ([1]) are refused.
[!WARNING] Props come from the browser and must be treated as untrusted input, even on
#[Locked]properties: they are assigned beforemount()runs. A component opened in a modal also does not run the middleware of its own route (auth,can, Filament's panel access, ...), only those of the page hosting<livewire:modal />. Always authorize inmount()and in every action:
Preparing Your Modals
Any allowed Livewire component can be displayed as a modal. However, certain features, such as stacking, require additional customization.
Creating a Simple Modal Component
This package provides two Blade components to simplify stacking and positioning:
x-livewire-modal::stack: Provides a basic layout with stacking capabilities.x-livewire-modal::modal: Handles positioning and stacking.
Wrap your content within these components:
Controlling the Modal Position
By default, modals are centered, but their position can be adjusted using the position prop:
Fullscreen Modal
To make a modal fullscreen, use the fullscreen prop:
Creating a Slideover Component
Opening a Modal
To open a modal, dispatch a modal-open event:
Preloading a Modal
To preload a modal, dispatch a modal-preload event with the same props used to open it:
Preloading a Modal on Hover
Using the custom Alpine directive, you can preload a modal when the user starts hovering over a button. This improves UX by ensuring faster modal openings.
Closing the Current Modal
To close the currently active modal, dispatch a modal-close event:
Closing All Modals
To close all modals at once:
Testing
Run the test suite with:
Changelog
For recent changes, see CHANGELOG.
Contributing
See CONTRIBUTING for contribution guidelines.
Security Vulnerabilities
For information on reporting security vulnerabilities, please review our security policy.
Credits
- Quentin Gabriele
- All Contributors
License
This package is licensed under the MIT License. See License File for details.
All versions of livewire-modal with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
livewire/livewire Version ^4.0
spatie/laravel-package-tools Version ^1.16