View source: R/shiny-swal-alert.R
shiny_alert2 | R Documentation |
Simple shiny alert that uses 'JavaScript' promises
shiny_alert2(
title = "Alert",
text = "",
icon = c("info", "warning", "success", "error"),
danger_mode = FALSE,
auto_close = TRUE,
buttons = NULL,
on_close = NULL,
session = shiny::getDefaultReactiveDomain()
)
close_alert2()
title |
title of the alert |
text |
alert body text (pure text) |
icon |
which icon to display, choices are |
danger_mode |
true or false; if true, then the confirm button turns
red and the default focus is set on the cancel button instead. To enable
danger mode, |
auto_close |
whether to close automatically when clicking outside of the alert |
buttons |
logical value or a named list, or characters. If logical, it indicates whether buttons should be displayed or not; for named list, the names will be the button text, see example; for characters, the characters will be the button text and value |
on_close |
|
session |
shiny session, see |
a temporary input ID, currently not useful
library(shiny)
library(dipsaus)
ui <- fluidPage(
use_shiny_dipsaus(),
actionButtonStyled('btn', 'btn')
)
server <- function(input, output, session) {
observeEvent(input$btn, {
shiny_alert2(
on_close = function(value) {
cat("Modal closed!\n")
print(value)
},
title = "Title",
text = "message",
icon = "success",
auto_close = FALSE,
buttons = list("cancel" = TRUE,
"YES!" = list(value = 1))
)
})
}
if(interactive()){
shinyApp(ui, server, options = list(launch.browser = TRUE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.