useShinyalert {shinyalert} | R Documentation |
Set up a Shiny app to use shinyalert
Description
This function is no longer required.
The first time a {shinyalert} message is shown, the required scripts are
automatically inserted to the Shiny app. Usually this is not an issue, but
in some unique cases this can sometimes cause the modal to appear glitchy
(such as inside RStudio's Viewer, on some old browsers, or if the modal contains
certain Shiny inputs).
If you notice issues with the UI of the modal, you may want to try to pre-load
the scripts when the Shiny app initializes by calling useShinyalert(force=TRUE)
anywhere in the UI.
Usage
useShinyalert(rmd, force = FALSE)
Arguments
rmd |
Deprecated, do not use this parameter. |
force |
Set to |
Value
Scripts that shinyalert
requires that are automatically
inserted to the app's <head>
tag.
See Also
Examples
if (interactive()) {
library(shiny)
library(shinyalert)
shinyApp(
ui = fluidPage(
useShinyalert(force = TRUE), # 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")
})
}
)
}