Tiny Confirmation Modal In Vanilla JavaScript

Category: Javascript , Modal & Popup | September 10, 2020
Views Total:1,032 views
Official Page:Go to website
Last Update:September 10, 2020


Tiny Confirmation Modal In Vanilla JavaScript


A tiny Vanilla JavaScript modal library that adds a custom, animated, beautiful confirm dialog with Promise support to your website/web app.

How to use it:

1. Insert the required JavaScript and CSS files into the document.

<link rel="stylesheet" href="simple-modal.css" />
<script src="simple-modal.js"></script>

2. Create a new confirm dialog and attach a callback to the Promise object.

async function openModal() {
      this.myModal = new SimpleModal("Confirm Dialog!", "Are You Sure", "Sure!", "No");
      try {
        const modalResponse = await myModal.question();
        alert(`The response is ${modalResponse}`);
      } catch(err) {

3. Launch the confirm dialog.


You Might Be Interested In:

Leave a Reply