Dialog Modal Native Show Modal
Create a native modal dialog using the dialog element with showModal and form method close for accessible interactions.
Code
<dialog id="confirm-dialog">
<form method="dialog">
<p>Are you sure you want to delete this item?</p>
<menu>
<button value="cancel">Cancel</button>
<button value="confirm" autofocus>Delete</button>
</menu>
</form>
</dialog>
<button onclick="document.getElementById('confirm-dialog').showModal()">
Delete item
</button>Report a problem with this exampleOpens a pre-filled issue on GitHub.