| useShinyalert {shinyalert} | R Documentation |
This function must be called from a Shiny app's UI in order for the
shinyalert function to work.
You can call useShinyalert() from anywhere inside the UI.
useShinyalert()
Scripts that shinyalert requires that are automatically
inserted to the app's <head> tag.
if (interactive()) {
library(shiny)
library(shinyalert)
shinyApp(
ui = fluidPage(
useShinyalert(), # Set up shinyalert
actionButton("btn", "Click me")
),
server = function(input, output) {
observeEvent(input$btn, {
# Show a simple modal
shinyalert(title = "You did it!", type = "success")
})
}
)
}