Hardik2972 / alert-for-web

Simple alert dialog component for web

Home Page:https://codersuresh.github.io/alert-for-web/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alert for Web - Show alert message on web page

npm version License: MIT

This is a simple script that shows an alert message on a web page. It can be used to show a message on a web page when a certain event occurs. For example, when a backup is completed, or when a long running process is finished.

installation

npm install alert-for-web

Usage

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Alert for Web</title>
    <!-- package css -->
    <link rel="stylesheet" href="https://www.unpkg.com/alert-for-web@0.1.2/dist/style.css">
    <script src="app.js" type="module">
  </head>
  <body>
    <button class="btn">Show Alert</button>
  </body>

app.js

//import package
import showAlert from "https://www.unpkg.com/alert-for-web@0.1.2/dist/main.js";

    //use any element to trigger the alert
    const btn = document.querySelector('.btn');

    btn.addEventListener("click", () => {
    //call the showAlert function
      showAlert({
        title: "Success",
        message: "This is a success alert",
        level: "success",
        button: "Close"
      })
    })

Options

Option Type Default Optional Description
title string null no The title of the alert
message string null no The message of the alert
level string success yes The level of the alert. Possible values are: success, warning, error.
button string Close yes The text of the button

License

MIT

Authors

About

Simple alert dialog component for web

https://codersuresh.github.io/alert-for-web/


Languages

Language:TypeScript 46.5%Language:HTML 28.1%Language:CSS 25.4%