zhaoheng / sweetalert

A beautiful replacement for JavaScript's "alert"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#SweetAlert

An awesome replacement for JavaScript's alert.

See it in action!

A success modal

#Usage

You can install SweetAlert through bower:

bower install sweetalert

Alternatively, download the package and reference the JavaScript and CSS files manually:

<script src="lib/sweet-alert.min.js"></script>
<link rel="stylesheet" type="text/css" href="lib/sweet-alert.css">

#Examples

The most basic message:

sweetAlert("Hello world!");

A message signaling an error:

sweetAlert("Oops...", "Something went wrong!", "error");

A warning message, with a function attached to the "Confirm"-button..

sweetAlert({
  title: "Are you sure?",
  text: "You will not be able to recover this imaginary file!",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "Yes, delete it!",
  closeOnConfirm: false
}, function(){
  swal("Deleted!",
  "Your imaginary file has been deleted.",
  "success");
});

View more examples

#Related projects

About

A beautiful replacement for JavaScript's "alert"

License:MIT License


Languages

Language:CSS 61.7%Language:JavaScript 38.3%