Description Usage Arguments Value Examples
A Shiny checkbox input.
1 2 3 | sa_checkbox(inputId, label, value = FALSE, color = "#555555", width = NULL)
update_sa_checkbox(session, inputId, label = NULL, value = NULL)
|
inputId |
The id of the input object. |
label |
The label to set for the input object. |
value |
logical, default toggle state. |
color |
character, hex or R color name. |
width |
The width of the input, e.g. |
session |
The session object passed to function given to shinyServer. |
HTML element that can be added to a UI definition.
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 33 | if (interactive()) {
library(shiny)
ui <- function(request) {
fluidPage(
use_access(),
fluidRow(bookmarkButton()),
fluidRow(
column(3,
actionButton("btn1", "Set to TRUE"),
actionButton("btn2", "Change label"),
sa_checkbox("cb1", "Show text A", FALSE, "firebrick", 200),
sa_checkbox("cb2", "Show text B", TRUE)
),
column(9, textOutput("txt1"), textOutput("txt2"))
)
)
}
server <- function(input, output, session) {
output$txt1 <- renderText(paste("Checkbox 1 input is set to", input$cb1))
output$txt2 <- renderText(paste("Checkbox 2 input is set to", input$cb2))
observeEvent(input$btn1, {
update_sa_checkbox(session, "cb1", value = TRUE)
})
observeEvent(input$btn2, {
update_sa_checkbox(session, "cb1", label = "Show text A 2")
})
}
shinyApp(ui, server, enableBookmarking = "url")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.