Show a Toast from Shiny
Description
Show a toast from the server of a Shiny app. The page needs a bc_toaster() for the toast to appear in.
Usage
bc_show_toast(
toast,
toaster = "toaster",
session = shiny::getDefaultReactiveDomain()
)
Arguments
| Argument | Description |
|---|---|
toast |
A bc_toast(). |
toaster |
String. The ID of the bc_toaster(). Defaults to "toaster". |
session |
The Shiny session. Defaults to the current session. |
Value
NULL, invisibly.
Examples
if (interactive()) {
library(shiny)
ui <- bc_page_sidebar(
bc_shiny_deps(),
sidebar = bc_sidebar(id = "sidebar"),
bc_button("Save", id = "save"),
bc_toaster()
)
server <- function(input, output, session) {
observeEvent(input$save, {
bc_show_toast(bc_toast("Saved", category = "success"))
})
}
shinyApp(ui, server)
}