checkbox_group: checkbox_group

Description Usage Arguments Examples

View source: R/checkbox_group.R

Description

Create a custom checkbox input group

Usage

1
2
3
4
5
6
7
8
checkbox_group(
  inputId,
  title,
  caption = NULL,
  choices,
  values = NULL,
  checked = FALSE
)

Arguments

inputId

a unique id for the input group

title

a title for the inputs

caption

an optional caption to display

choices

an array of choices

values

an array of values to display

checked

an array of logical values to check an input at start

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
34
35
36
37
38
39
40
41
42
43
44
if (interactive()) {
  librar(shiny)
  ui <- tagList(
    iceComponents::use_iceComponents(),
    tags$h2("Checkbox group example"),
    iceComponents::checkbox_group(
      inputId = "pizza_toppings",
      title = "Your favorite pizza toppings",
      caption = "Select your favorite toppings",
      choices = c(
        "Pepperoni",
        "Mushrooms",
        "Onions",
        "Sausage",
        "Bacon",
        "Extra Cheese",
        "Black Olives",
      ),
      checked = TRUE
    ),
    tags$button(
      id = "reset",
      class = "shiny-bound-input action-button",
      "Reset Toppings"
    ),
    tags$button(
      id = "clear",
      class = "shiny-bound-input action-button",
      "Clear Selections"
    )
  )
  server <- function(input, output) {
    observe({
      print(input$pizza_toppings)
    })
    observeEvent(input$reset, {
      iceComponents::reset_checkbox_group(inputId = "pizza_toppings")
    })
    observeEvent(input$clear, {
      iceComponents::clear_checkbox_group(inputId = "pizza_toppings")
    })
  }
  shinyApp(ui, server)
}

InControlofEffects/iceComponents documentation built on April 1, 2021, 5:51 a.m.