Build a shad_dialog() (or alert dialog, sheet, drawer) in the server
function and show it, the way shiny::showModal() works – no need to place
it in the UI up front and no trigger.
Usage
shad_show_dialog(
overlay,
transient = TRUE,
session = shiny::getDefaultReactiveDomain()
)Arguments
- overlay
A
shad_dialog(),shad_alert_dialog(),shad_sheet(), orshad_drawer()tag.- transient
If
TRUE(default), the overlay is destroyed and removed from the document once it closes. IfFALSE, it stays in the document and can be reopened withshad_dialog_open().- session
The Shiny session.
Details
The overlay is inserted at the end of <body>, opens itself once its
JavaScript instance exists, and by default removes itself from the document
after it closes (transient = TRUE). Its inputs are live while it is open –
read input$<id> inside it as usual – so transient = FALSE is the right
call when you need those values to survive the close.
Because the tag is built in the server, its ids are namespaced by the module
that built it exactly like any other UI; shad_remove_dialog() takes the
unnamespaced id.
Examples
if (interactive()) {
server <- function(input, output, session) {
shiny::observeEvent(input$open, {
shad_show_dialog(shad_dialog(
"confirm", title = "Delete project?",
description = "This cannot be undone.",
footer = shad_dialog_close_button()
))
})
}
}