# NOT RUN {
library(shiny)
library(shinyToastify)
ui <- fluidPage(
useShinyToastify(),
br(),
actionButton("btn", "Show toast", class = "btn-primary btn-lg")
)
server <- function(input, output, session){
toastTransitions <- c(
"Zoom", "Bounce", "Flip", "Slide"
)
observeEvent(input[["btn"]], {
toastTransition <- toastTransitions[1L + (input[["btn"]] %% 4L)]
html <- HTML(
'<span style="font-size: 30px; font-family: cursive;">',
paste0(toastTransition, " transition"),
'</span>',
)
showToast(
session,
input,
text = html,
type = "success",
transition = tolower(toastTransition),
autoClose = 3000,
style = list(
border = "4px solid crimson",
boxShadow = "rgba(0, 0, 0, 0.56) 0px 22px 30px 4px"
)
)
})
}
if(interactive()){
shinyApp(ui, server)
}
# }
Run the code above in your browser using DataLab