bs5dialog

Introduction

Displays a message with customizable options

Usage Examples

ESM

import { message } from '@ymlluo/bs5dialog';

const options = {
  position: "center",
  type: "success",
  closeBtn: true,
  background: "#28a745",
  textColor: "#fff",
  fontsize: "1rem",
  icon: "check-circle",
  iconClass: "bi",
  iconStyle: "font-size: 1.5rem;",
  timeout: 5000,
  onClose: function () {},
  onClosed: function () {}
};

const msg = message("This is a success message", options);

CJS

const { message } = require('@ymlluo/bs5dialog');

const options = {
  position: "center",
  type: "success",
  closeBtn: true,
  background: "#28a745",
  textColor: "#fff",
  fontsize: "1rem",
  icon: "check-circle",
  iconClass: "bi",
  iconStyle: "font-size: 1.5rem;",
  timeout: 5000,
  onClose: function () {},
  onClosed: function () {}
};

const msg = message("This is a success message", options);

UMD

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>bs5dialog Message Example</title>
    <!-- Include Bootstrap 5 CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="../bs5dialog.css" />
    <script src="../bs5dialog.js"></script>
  </head>
  <body>
    <button id="show-message-btn">Show Message</button>
    <script>
      const showMessageBtn = document.getElementById("show-message-btn");
      showMessageBtn.addEventListener("click", () => {
        const options = {
          position: "center",
          type: "success",
          closeBtn: true,
          background: "#28a745",
          textColor: "#fff",
          fontsize: "",
          icon: "bs5-circle-check",
          iconClass: "",
          iconStyle: "",
          timeout: 0,
          onClosed: function () {}
        };
        const msg = bs5dialog.message("This is a success message", options);
      });
    </script>
  </body>
</html>

Parameters

List of Event Listeners