Quantcast
Channel: Latest Free Bootstrap 5/4/3 Extensions & Plugins - CSS Script
Viewing all articles
Browse latest Browse all 164

Tiny Bootstrap 5 Modal Generator – BS5ModalJS

$
0
0
Tiny Bootstrap 5 Modal Generator - BS5ModalJS

BS5ModalJS is a JavaScript library that helps developers generate Bootstrap 5 modal windows using only JavaScript.

How to use it:

1. Load the BS5ModalJS JavaScript library in your Bootstrap 5 project.

<!-- Bootstrap 5 -->
<link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
<script src="/path/to/cdn/bootstrap.bundle.min.js"></script>

<!-- BS5ModalJS Library -->
<script src="BS5Modal.js"></script>

2. Create a new instance of the Bootstrap 5 modal window.

  • id: unique modal ID
  • title: Modal title
  • message: Modal content
  • callBack: fired after the confirm button is clicked
// BSModal(id, title, message, callBack = null);
let myModal = new BSModal("myModal","Modal Title", "Modal Content?", function() {
    // do something
});

3. Create a toggle button to launch the modal window.

// toggleButton(innerText = "Submit", classes = "btn btn-outline-primary")
let toggleBtn = myModal.toggleButton("Launch", "btn btn-outline-danger");

4. Append the toggle button to the page.

document.querySelector("#demo").appendChild(toggleBtn);

The post Tiny Bootstrap 5 Modal Generator – BS5ModalJS appeared first on CSS Script.


Viewing all articles
Browse latest Browse all 164

Trending Articles