Skip to main content

Command Palette

Search for a command to run...

A better way to show alerts in your next projects

Published
β€’1 min read
A better way to show alerts in your next projects
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

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

  • Import Sweet Alert to your project
    https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js
    
  • Now let's create three different types of alerts 1) Success
    const success = () => {
    swal ( "Welcome!" ,  "Follow at @codewithsnowbit" ,  "success" )
    }
    
    2)Warn
    const warn = () => {
    swal ( "You forgot something!" ,  "Follow at @codewithsnowbit" ,  "warning" )
    }
    
    3) Error
    const error = () => {
     swal ( "Oops" ,  "Something's not right" ,  "error" )
    }
    
    Check out the live demo:

Thank you for reading

More from this blog

D

Dhairya Shah

119 posts