Easily Build Confirmation Popups with the confirmDialog.js Library

Category: Javascript , Modal & Popup | January 26, 2025
Author:izisaurio
Views Total:522 views
Official Page:Go to website
Last Update:January 26, 2025
License:MIT

Preview:

Easily Build Confirmation Popups with the confirmDialog.js Library

Description:

A compact and sleek JavaScript library for building custom confirmation dialogs that enhance user experience. Built-in support for 5 languages (English, French, Spanish, German, Portuguese) and easy expansion for global reach.

How to use it:

1. Download and import the confirmDialog.js script.

<script src="confirmDialog.js"></script>

2. Create a new confirm dialog instance.

const dialog = new ConfirmDialog({
      message: 'Do you want to confirm this action?',
      okText: 'Ok',
      cancelText: 'Cancel'
});

3. Display a confirm dialog on the page. It will return Promises to handle user confirmation or cancellation actions.

dialog.show('Are You Sure?').then((result) => {
  console.log(result.ok);
});

4. More options to customize the confirm dialog.

const dialog = new ConfirmDialog({
      // custom CSS classes
      textClass: '',
      okClass: '',
      useCancel: true,
      cancelClass: '',
      modalClass: '',
      // enable themes
      success: false,
      warning: false,
      error: false,
      
});

Changelog:

v1.1.1 (01/26/2025)

  • Update confirmation dialog styles and functionality;

You Might Be Interested In:


Leave a Reply