Elegant Alert/Confirm/Toast Dialog Box In JavaScript

Cute Alert

img

I designed this JS library as an open-source project with the purpose of providing beautiful alert box messages for your website. Feel free to contribute with a pull request or suggestions.

Installation Instructions

  • Clone this repository into your project’s lib folder.
  • Import both “style.css” and “cute-alert.js” into your code just like the image below:

img

Docs

It’s way too simple for you to import this lib into your code, all you have to do is call cuteAlert() and pass its arguments in object notation.

buttonText is an optional parameter, by default it’s set as “OK”.

type will define what kind of alert box will be shown.

img img img img

cuteAlert()returns a Promise, so you can use then to execute an action after the alert box frame is closed.

img

As for the question alert box, you can choose what you want to do after any of the buttons is pressed with then aswell.

confirmText and cancelText are both optional, by the default they are set as “Confirm” and “Cancel” respectively.

img

Close button as a circle

If you wish to have the close button styled as a circle, you need to pass closeStyle: "circle as an argument in cuteAlert().

img

Toasts (NEW FEATURE!!!)

It’s even easier to use toasts, all you have to do is call cuteToast() and pass type, message and timer(in miliseconds) as its arguments.

img img img img

It also returns a Promise, so you can use then to execute an action after the toast is closed or reaches its end by a timer.

Alert Box Design

Dev

Contributors

Download Details:

Author: gustavosmanc

GitHub: https://github.com/gustavosmanc/cute-alert

#javascript #programming

Elegant Alert/Confirm/Toast Dialog Box In JavaScript
16.75 GEEK