sa_checkbox: Checkbox input

Description Usage Arguments Value Examples

View source: R/checkbox.R

Description

A Shiny checkbox input.

Usage

1
2
3
sa_checkbox(inputId, label, value = FALSE, color = "#555555", width = NULL)

update_sa_checkbox(session, inputId, label = NULL, value = NULL)

Arguments

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. '400px', or '100%'; see shiny::validateCssUnit.

session

The session object passed to function given to shinyServer.

Value

HTML element that can be added to a UI definition.

Examples

 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")

}

leonawicz/shinyaccess documentation built on Aug. 15, 2020, 12:40 a.m.