Elmish.SweetAlert docs

SweetAlert2 integration in Fable, made with <Heart /> by Zaid-Ajaj. Implemented as Elmish commands, for installation instructions see the repo at github.

SimpleAlert
ToastAlert
ConfirmAlert
ConfirmToastAlert
InputAlert
SelectAlert

SimpleAlert API

SimpleAlert lets you create highly customizable SweetAlert modals that show information.


dispatch SimplestAlert
| SimplestAlert ->
    let alert = SimpleAlert("Simple but sweet")
    state, SweetAlert.Run(alert)

dispatch SimpleAlertWithTitle
| SimpleAlertWithTitle ->
    let alert = SimpleAlert("Is that still a thing?").Title("The Internet")
    state, SweetAlert.Run(alert)

dispatch SuccessAlert
| SuccessAlert ->
    let successAlert =
        SimpleAlert("Your account has been succesfully created!")
            .Title("Server")
            .Type(AlertType.Success)

    state, SweetAlert.Run(successAlert)

dispatch Timeout
| Timeout ->
    let errorAlert =
        SimpleAlert("That didn't go as we expected")
            .Title("We are sorry...")
            .Type(AlertType.Error)
            .Timeout(3000)

    state, SweetAlert.Run(errorAlert)

dispatch HideConfirm
| HideConfirm ->
    let successAlert =
        SimpleAlert("You have levelled up!")
            .Title("Congrats")
            .Type(AlertType.Success)
            .ConfirmButton(false)
            .Timeout(2000)

    state, SweetAlert.Run(successAlert)

dispatch WithImage
| WithImage ->
    let alert =
        SimpleAlert("Modal with a custom image.")
            .Title("Sweet!")
            .ImageUrl("https://unsplash.it/400/200")
            .ImageHeight(200)
            .ImageWidth(400)
            .UseAnimation(false)

    state, SweetAlert.Run(alert)

dispatch CustomConfirmBtnText
| CustomConfirmBtnText ->
    let alert =
        SimpleAlert("We are going to launch the missiles")
            .Title("Heads up!")
            .Type(AlertType.Warning)
            .ConfirmButtonText("Oki doki!")

    state, SweetAlert.Run(alert)