Download the PHP package rishadblack/wire-modals without Composer

On this page you can find all versions of the php package rishadblack/wire-modals. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wire-modals

Wire Modals

On-demand Livewire components with Bootstrap 5 modals.

A button mounts a Livewire component the first time it is clicked, calls an action on it, keeps it alive while its modal is open, and unmounts it when the modal closes. The component owns its own modal markup, so one component can drive several modals (edit, options, delete confirmation) and a list page never renders a modal it does not need.

Contents

Requirements

Dependency Version
PHP 8.3 or newer
Laravel 11, 12 or 13
Livewire 3 or 4 (Alpine is bundled with Livewire)
Bootstrap 5.3, loaded as window.bootstrap

Installation

1. Install the package.

2. Load the browser script after Bootstrap and before Livewire starts. With Vite, in resources/js/app.js:

The script registers the wire:modal directive and two Alpine components. It uses no other library.

3. Place the host once in your layout, anywhere inside <body>:

4. Optionally import the small stylesheet and publish the config. The stylesheet (resources/css/wire-modals.css) only adds a .wire-modals-body-tall helper for tall scrolling bodies and a progress cursor on triggers while they load; the modal component itself ships no CSS.

Rebuild your assets afterwards (npm run build).

Your first modal

Create a Livewire component and add the trait. Actions are public methods named open*Modal or marked with the #[ModalAction] attribute. They receive one array with the trigger's id and data.

The view declares the modal. Its id must equal the name passed to modalOpen():

Then trigger it from any page:

modals.note-edit is the Livewire name of App\Livewire\Modals\NoteEdit.

How it works

  1. A click on a wire:modal element builds a payload from the element's attributes (nothing is evaluated) and calls load() on the host component.
  2. The host checks the payload, the component name and the limits, then mounts the component with the payload. Livewire calls the component's action in the same request.
  3. The action fills properties and calls modalOpen('NoteModal'), which shows the Bootstrap modal in the browser.
  4. When that modal closes, the host unmounts the component. Clicking the trigger again mounts a fresh instance.

Everything the browser sends is validated twice, once by the host and once by the component, and only allow-listed methods can be called. See Security notes.

Triggers

A trigger is any element with a wire:modal attribute:

Attribute Required Meaning
wire:modal="modals.note-edit" yes Component name. modals.note-edit@noteDelete names the action too
wire:modal.action="openNoteModal" no Action method. Defaults to the @action part, then to the method marked #[ModalAction(default: true)]
wire:modal.id="7" no Record key, delivered as $data['id']
wire:modal.key="notes-7" no Instance key. Triggers with different keys mount separate instances
data-folder-id="3" no Any data-* attribute becomes $data['data']['folder_id']. Prefixes in data_exclusions (default data-bs-*, data-wire-modals-*) are skipped

All values arrive as strings. Keys are lower-cased kebab → snake (data-order-type-id → order_type_id); keys that are not plain identifiers are dropped.

Blade component

Renders a <button type="button"> by default; tag="a" renders a link. Values are validated at render time and escaped by Blade.

Server-side builder

For table action columns or any PHP context:

Loading state

While the host request is pending the element gets data-wire-modals-loading="true", aria-busy="true" and (for buttons) disabled. A second click during that time is ignored.

Opening from PHP

Another component can ask the host to load something:

Actions and payload

An action is a public method on the component that is either named to match action_patterns (default open*Modal) or marked #[ModalAction]. Methods declared by Livewire or by this package are never callable, whatever the config says. Lifecycle methods (mount, render, updated*...) are refused too.

Every action receives one array:

id and data are request input. Load records yourself, cast values, and authorise (see below). The package bounds the input: ids up to 191 characters, data up to max_payload_bytes, three levels deep, 50 values, scalars only.

Mark one method with #[ModalAction(default: true)] and triggers can omit the action entirely.

Re-entry and several modals per component

While a component is mounted, another click on a trigger for the same component (same key) does not mount it again: the host forwards the payload and the action runs on the existing instance. That is how a list page opens the same edit modal for different rows, and how a button inside a modal can open another modal of the same component.

Declare as many <x-wire-modals::modal> elements as you need in one view and open each by id.

Sub-modals and keeping the component alive

Closing a modal opened with modalOpen('X') unmounts the component. For a secondary modal that must not end the component (options, pickers, previews) pass keepComponent:

modalClose('X') hides a modal. closeComponent() unmounts the component explicitly; any of its modals still open are hidden first so Bootstrap removes backdrops cleanly.

Nested modals: one, then two, then three

Modals stack. The package raises each newly shown modal and its backdrop above the ones already open and keeps the page locked while any modal is visible, so a chain of steps in one component is just three modals and a few method calls:

Inside the modals, "Next" can be a plain wire:click="openStepTwoModal" or a trigger for the same component (<x-wire-modals::trigger component="modals.wizard" action="openStepThreeModal">): the host re-enters the mounted instance either way.

Modals across components

A modal can open a modal of another component. The second component is mounted on top of the first, does its work, reports back with an ordinary Livewire event and unmounts itself; the first component and its modal stay where they were.

Delete with confirmation

Use a second modal in the same component. The delete action is not named open*Modal, so it carries the attribute:

Authorisation

Override the hook to plug in your permission system. Returning false refuses the call, logs it and dispatches wire-modals:rejected.

#[ModalAction(ability: 'notes.delete')] stores a hint on the method; the package does not interpret it, your hook can read it through reflection or you can simply switch on $action.

Configuration reference

<x-wire-modals::modal> props: id (required), title, size, centered, scrollable, fullscreen (true or a breakpoint such as md), backdrop, keyboard, close-button. Slots: default (body), button (header actions), footer.

Browser events

All events are plain window events; listen with x-on:wire-modals:opened.window or window.addEventListener.

Event Detail When
wire-modals:opened { modal, owner } A modal was shown. owner is the component that will be unmounted on close, or null
wire-modals:hidden { modal, owner } A lifetime-owning modal closed (the host reacts to it)
wire-modals:rejected { source, action, reason } The host or a component refused a payload
wire-modals:open, wire-modals:close, wire-modals:dispose Dispatched by the trait; handled by the package

Security notes

Legacy mode

For applications that migrated from a hand-rolled loader with the historical names (wire:load:component, loadComponent, closeComponent, modalOpen, modalClose, onConfirmAlert, onCancelAlert, set-tab):

New code should not use any of this.

Testing

In your application, test components with Livewire's test helpers:

Rejections dispatch wire-modals:rejected with source, action and reason.

Customising the markup

Keep the x-data, x-on:wire-modals:* and wire:ignore.self attributes on the modal root and the data-wire-modals-* attributes on the host root; the browser layer depends on them.

Troubleshooting

License

MIT.


All versions of wire-modals with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/view Version ^11.0|^12.0|^13.0
livewire/livewire Version ^3.0|^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rishadblack/wire-modals contains the following files

Loading the files please wait ...