toast | R Documentation |
Toast notifications.
toast(
id,
...,
class = "",
position = c("top-right", "top-left", "bottom-right", "bottom-left")
)
id |
ID of toast, used to show/hide from server. |
... |
Content, generally |
class |
Any additional classes. |
position |
Position of the toast. |
library(shiny)
ui <- fluidPage(
theme = bslib::bs_theme(version = 5L),
toast(
"toast",
toastHeader(
strong(
"Toast",
class = "me-auto"
)
),
toastBody("The body of the toast!")
),
h1("Hello"),
actionButton("show", "Show toast"),
actionButton("hide", "Hide toast")
)
server <- \(input, output, session){
observeEvent(input$show, {
toast_show("toast", auto_hide = FALSE)
})
observeEvent(input$hide, {
toast_hide("toast")
})
}
if(interactive())
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.