DEV Community

Cover image for A better way to show alerts in your next projects
Dhairya Shah
Dhairya Shah

Posted on • Originally published at codewithsnowbit.hashnode.dev

A better way to show alerts in your next projects

Are you bored with the default alert(); of the browser?

Even I am bored with that error 😔

But now not anymore, there is a powerful JavaScript library to create amazing alerts - Sweet Alert

Let's create some amazing alerts

https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js
Enter fullscreen mode Exit fullscreen mode
  • Now let's create three different types of alerts 1) Success
const success = () => {
  swal ( "Welcome!" ,  "Follow at @codewithsnowbit" ,  "success" )
}
Enter fullscreen mode Exit fullscreen mode

2)Warn

const warn = () => {
  swal ( "You forgot something!" ,  "Follow at @codewithsnowbit" ,  "warning" )
}
Enter fullscreen mode Exit fullscreen mode

3) Error

const error = () => {
   swal ( "Oops" ,  "Something's not right" ,  "error" )
}
Enter fullscreen mode Exit fullscreen mode

Check out the live demo:


Thank you for reading

Top comments (0)