Skip to content

zk-modal ​

A modal window, a native <dialog>.

Props ​

PropTypeDefaultDescription
idstringrequiredIdentifier, used to open it and to build the ids of the title and the body
titlestring|nullnullTitle: gives the accessible name
alertboolfalserole="alertdialog"
closedbystring'any'any (Escape and a click outside), closerequest or none
closeLabelstring'Close'Accessible name of the close button
classstring|nullnullCSS class(es) merged onto the root element

Undeclared attributes forward to the root element.

Slots ​

SlotDescription
defaultBody
footerFooter with the actions

The close button and any <form method="dialog"> close it with no script. To open it, use a button with commandfor and command="show-modal" (supported by current browsers) or, for older ones, data-zk-modal="confirm" on the button with zk-scripts.

Class hooks: modal, modal-header, modal-title, modal-close, modal-body, modal-footer. Style the open one with .modal[open] and the backdrop with .modal::backdrop.

Examples ​

Open it ​

blade
<button commandfor="confirm" command="show-modal">Delete</button>

<x-zk-modal id="confirm" title="Delete this project?">
    This cannot be undone.
    <x-slot:footer>
        <form method="dialog">
            <button>Cancel</button>
            <button value="delete">Delete</button>
        </form>
    </x-slot>
</x-zk-modal>

Documentation of 3.2.0 , built from c93e21f on 3.2.0 by pipeline #2919741884 on 2026-10-06.