Learn R Programming

shinyWidgets (version 0.4.1)

confirmSweetAlert: Launch a confirmation dialog

Description

Launch a popup to ask confirmation to the user

Usage

confirmSweetAlert(session, inputId, title = "Are you sure ?", text = NULL,
  type = NULL, danger_mode = FALSE, btn_labels = c("Cancel", "Confirm"))

Arguments

session

The session object passed to function given to shinyServer.

inputId

The input slot that will be used to access the value.

title

Title of the alert.

text

Text of the alert.

type

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

danger_mode

Logical, activate danger mode (focus on cancel button).

btn_labels

Labels for buttons.

See Also

sendSweetAlert, inputSweetAlert

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
if (interactive()) {

library("shiny")
library("shinyWidgets")


ui <- fluidPage(
  tags$h1("Confirm sweet alert"),
  actionButton(
    inputId = "go",
    label = "Launch confirmation dialog"
  ),
  verbatimTextOutput(outputId = "res")
)

server <- function(input, output, session) {

 observeEvent(input$go, {
   confirmSweetAlert(
     session = session, inputId = "myconfirmation", type = "warning",
     title = "Want to confirm ?", danger_mode = TRUE
   )
 })

  output$res <- renderPrint(input$myconfirmation)

}

shinyApp(ui = ui, server = server)

}

# }

Run the code above in your browser using DataLab