Modals are implemented using the Stimulus modal_controller
or overriding the Turbo confirm method.
<form>
<button
class="btn btn-secondary"
data-turbo-confirm="Are you sure?"
data-turbo-confirm-description="This action is permanent and cannot be undone."
>Confirm</button>
</form>
<div data-controller="modal">
<button class="btn btn-secondary" data-action="click->modal#open:prevent">Open Small Modal</button>
<dialog class="modal rounded-lg max-w-sm max-h-screen w-full bg-transparent backdrop:backdrop-blur-sm backdrop:bg-black/50" data-modal-target="dialog" data-action="click->modal#backdropClose">
<div class="p-6 bg-white dark:bg-gray-900 dark:text-gray-200">
<button type="button" data-action="modal#close:prevent" class="hover:cursor-pointer absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg>
<span class="sr-only">Close</span>
</button>
<h2 class="text-lg mb-2">Are you sure?</h2>
<p class="text-sm mb-2">Are you sure you want to do that. Seriously?</p>
<div class="flex justify-end items-center flex-wrap gap-2 mt-4">
<button class="btn btn-secondary" data-action="click->modal#close:prevent">Cancel</button>
<button class="btn btn-primary" data-action="click->modal#close:prevent">Continue</button>
</div>
</div></dialog></div>
<div data-controller="modal">
<button class="btn btn-secondary" data-action="click->modal#open:prevent">Open Medium Modal</button>
<dialog class="modal rounded-lg max-w-md max-h-screen w-full bg-transparent backdrop:backdrop-blur-sm backdrop:bg-black/50" data-modal-target="dialog" data-action="click->modal#backdropClose">
<div class="p-6 bg-white dark:bg-gray-900 dark:text-gray-200">
<button type="button" data-action="modal#close:prevent" class="hover:cursor-pointer absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg>
<span class="sr-only">Close</span>
</button>
<h2 class="text-lg mb-2">Are you sure?</h2>
<p class="text-sm mb-2">Are you sure you want to do that. Seriously?</p>
<div class="flex justify-end items-center flex-wrap gap-2 mt-4">
<button class="btn btn-secondary" data-action="click->modal#close:prevent">Cancel</button>
<button class="btn btn-primary" data-action="click->modal#close:prevent">Continue</button>
</div>
</div></dialog></div>
<div data-controller="modal">
<button class="btn btn-secondary" data-action="click->modal#open:prevent">Open Large Modal</button>
<dialog class="modal rounded-lg max-w-lg max-h-screen w-full bg-transparent backdrop:backdrop-blur-sm backdrop:bg-black/50" data-modal-target="dialog" data-action="click->modal#backdropClose">
<div class="p-6 bg-white dark:bg-gray-900 dark:text-gray-200">
<button type="button" data-action="modal#close:prevent" class="hover:cursor-pointer absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg>
<span class="sr-only">Close</span>
</button>
<h2 class="text-lg mb-2">Are you sure?</h2>
<p class="text-sm mb-2">Are you sure you want to do that. Seriously?</p>
<div class="flex justify-end items-center flex-wrap gap-2 mt-4">
<button class="btn btn-secondary" data-action="click->modal#close:prevent">Cancel</button>
<button class="btn btn-primary" data-action="click->modal#close:prevent">Continue</button>
</div>
</div></dialog></div>
<div data-controller="modal">
<button class="btn btn-secondary" data-action="click->modal#open:prevent">Open Fullscreen Modal</button>
<dialog class="modal m-0 h-full w-full max-h-full max-w-full bg-transparent backdrop:backdrop-blur-sm" data-modal-target="dialog" data-action="click->modal#backdropClose">
<div class="p-6 w-full h-full bg-white dark:bg-gray-900">
<button type="button" data-action="modal#close:prevent" class="hover:cursor-pointer absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg>
<span class="sr-only">Close</span>
</button>
<div class="flex items-center h-full">
<div class="w-2/3 mx-auto">
<h2 class="text-lg mb-2">Are you sure?</h2>
<p class="text-sm mb-2">Are you sure you want to do that. Seriously?</p>
<div>
<button class="btn btn-secondary" data-action="click->modal#close:prevent">Cancel</button>
<button class="btn btn-primary" data-action="click->modal#close:prevent">Continue</button>
</div>
</div>
</div>
</div></dialog></div>