if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(
useShinyjs(), # Set up shinyjs
shiny::actionButton("btn", "Click me"),
shiny::p(id = "element", "Watch what happens to me")
),
server = function(input, output, session) {
shiny::observe({
if (input$btn == 0) {
return(NULL)
}
# Change the following line for more examples
toggle("element")
})
}
)
}
# The shinyjs function call in the above app can be replaced by
# any of the following examples to produce similar Shiny apps
toggle(id = "element")
toggle("element", TRUE)
toggle("element", TRUE, "fade", 2)
toggle(id = "element", time = 1, anim = TRUE, animType = "slide")
show("element")
show(id = "element", anim = TRUE)
hide("element")
hide(id = "element", anim = TRUE)Run the code above in your browser using DataLab