Description Usage Arguments See Also Examples
html_class
will add or remove a class from an HTML element.
html_addclass
and html_unclass
are shortcut functions.
1 2 3 4 5 | html_class(id, classname, add = TRUE)
html_unclass(id, classname)
html_addclass(id, classname)
|
id |
shiny input id |
classname |
class name |
add |
if TRUE, class will be added, if FALSE class will be deleted |
Other javascript functions: ability
,
activate
, click_event
,
html_toogle
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 31 32 | library(shinytools)
classes <- c("primary", "secondary", "success",
"danger", "warning", "info")
if (interactive()) {
options(device.ask.default = FALSE)
ui <- fluidPage(
titlePanel("Hello dghiesse!"),
load_jstools(),
sidebarLayout(
sidebarPanel(
selectInput("class", "Variable:", classes)
),
mainPanel(
actionButton("anybutton", "watch this button",
class = "btn-info")
)
)
)
server <- function(input, output) {
observeEvent(input$class, {
for(i in classes){
html_unclass("anybutton", paste0("btn-", i))
}
html_addclass("anybutton", paste0("btn-", input$class))
})
}
print(shinyApp(ui, server))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.