Installing SimpleToast is as easy as adding a script tag:
<script src="https://cdn.jsdelivr.net/gh/itaypanda/simpletoast@master/SimpleToast.min.js"></script>
// Initalize the toast library
toastInit();
// Show a success toast
toast("Success!", "SimpleToast is online!", toastStyles.success);
// Show an error toast
toast("Error!", "Whoops! we broke something.", toastStyles.error);
// Show a warning toast
toast("Warn!", "Field X is invalid.", toastStyles.warn);
// Show an info toast
toast("FYI!", "FYI - Info toast works.", toastStyles.info);
A custom style must have a color and an icon proerties:
// Defining the style
const customStyle = {
color: "purple", // Tailwind CSS color. Ex: [#ffffff].
icon: "<div></div>" // Doesn't have to be an svg.
};
// Using it
toast('My own custom style!', 'This is a SimpleToast custom style', customStyle);
All of the information you need can be found at this project's GitHub repo: https://github.com/itaypanda/SimpleToast