📜  sweetalert realrashid (1)

📅  最后修改于: 2023-12-03 15:05:25.559000             🧑  作者: Mango

SweetAlert by RealRashid

SweetAlert is a beautiful, responsive, customizable and versatile popup/alert dialog box library for JavaScript released by RealRashid. It can be used for a wide range of applications, from notifying users of successful or failed actions, to asking for confirmation before dangerous actions like deleting or overwriting data.

Features
  • Beautifully designed with a modern and sleek interface
  • Responsive and mobile-friendly
  • Customizable with various configuration options
  • Pre-built dialogs for common tasks like prompting for input, showing success or error messages, and more
  • Easy to use and integrate with existing code
  • Supported by all major web browsers and platforms
Getting Started

To use SweetAlert, simply download and include the script and CSS files in your project, and initialize it using JavaScript:

<script src="sweetalert.min.js"></script>
<link rel="stylesheet" href="sweetalert.css">
<script>
    swal("Hello World!");
</script>

This will display a simple SweetAlert dialog box with the text "Hello World!".

Examples
Confirming an Action
swal({
    title: "Are you sure?",
    text: "You will not be able to recover this data!",
    icon: "warning",
    buttons: true,
    dangerMode: true,
})
.then((willDelete) => {
    if (willDelete) {
        swal("Poof! Your data has been deleted!", {
            icon: "success",
        });
    } else {
        swal("Your data is safe!");
    }
});
Prompting for Input
swal("What's your name?", {
    content: "input",
})
.then((value) => {
    swal(`Hello, ${value}!`);
});
Showing Success Messages
swal("Good job!", "You clicked the button!", "success");
Displaying Errors
swal("Oops...", "Something went wrong!", "error");

Conclusion

SweetAlert by RealRashid is a powerful and elegant popup/alert dialog box library that is perfect for all web developers. It is customizable, responsive, and easy to use, making it a valuable tool for any project. Its pre-built dialogs make it easy to prompt users for input, confirm actions, and display success or error messages. With SweetAlert, your web applications will look great and function even better.