Description Usage Arguments Note Author(s) See Also Examples
Those functions can be used to change an elements classes.
1 2 3 4 5 | add_class(ids, class_name)
remove_class(ids, class_name)
toggle_class(ids, class_name, condition = NULL)
|
ids |
Character vector, id(s) of the element(s) to change. |
class_name |
Name of the class to add/remove/toggle. |
condition |
Condition to use for toggling the class, can be of length one or length of ids. |
If you have trouble with these functions, please make sure that you
either - use any dqshiny element in your UI - load the package with
library
- use init
at the beginning of your UI!
richard.kunze
Other js handler:
enable()
,
hide()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
tags$head(tags$style(".orange{background:#ff8f00}")),
actionButton("add", "Add Class"),
actionButton("remove", "Remove Class"),
actionButton("toggle", "Toggle Class"),
actionButton("toggle_cond", "Toggle Class with Condition"),
checkboxInput("condition", "orange"),
fluidRow(id = "row",
dq_space(), # this is needed to make everything work
actionButton("example", "EXAMPLE"),
dq_space() # this is just for the alignment ;)
)
),
server = function(input, output) {
observeEvent(input$add, add_class("row", "orange"))
observeEvent(input$remove, remove_class("row", "orange"))
observeEvent(input$toggle, toggle_class("row", "orange"))
observeEvent(
input$toggle_cond,
toggle_class("row", "orange", input$condition)
)
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.