Learn R Programming

shinyWidgets (version 0.3.0)

receiveSweetAlert: Display a Sweet Alert

Description

Send a message from the server and launch a sweet alert in the UI.

Usage

receiveSweetAlert(messageId)

sendSweetAlert(messageId, title = "Title", text = "Text", type = NULL, html = FALSE)

Arguments

messageId

The sweet alert id.

title

Title of the alert

text

Text of the alert

type

Type of the alert : null, info, success, warning or error

html

Logical. Use HTML in the text

Examples

Run this code
# NOT RUN {
if (interactive()) {
 shinyApp(
  ui = fluidPage(
    tags$h1("Click the button"),
    actionButton(inputId = "success", label = "Launch a success sweet alert"),
    receiveSweetAlert(messageId = "successSw")
  ),
  server = function(input, output) {
    observeEvent(input$success, {
      sendSweetAlert(
        messageId = "successSw", title = "Success !!", text = "All in order", type = "success"
      )
    })
  }
 )
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab