Learn R Programming

yonder (version 0.1.0)

checkboxInput: Checkbox inputs

Description

Reactive checkbox and checkbar inputs. Users may select one or more choices. The checkbox input appears as a standard checkbox or set of checkboxes. The checkbar input appears similar to a group of buttons, but with a checked or highlighted state. When a checkbox or checkbar input has no selected choices the reactive value is NULL. Switch inputs differ from checkboxes only in appearance.

Usage

checkboxInput(id, choices, values = choices, selected = NULL, ...,
  inline = FALSE)

switchInput(id, choices, values = choices, selected = NULL, ...)

checkbarInput(id, choices, values = choices, selected = NULL, ...)

Arguments

id

A character string specifying the id of the reactive input.

choices

A character string or vector specifying a label or labels for the checkbox or checkbar.

values

A character string or vector specifying values for the checkbox or checkbar input, defaults to choice or values, respectively.

selected

One or more of values specifying which choices are selected by default, defaults to NULL, in which case no choices are initially selected.

...

Additional named arguments passed as HTML attributes to the parent element.

inline

One of TRUE or FALSE specifying if the checkbox input choices render inline or stacked, defaults to FALSE, in which case the choices are stacked.

See Also

Other inputs: buttonGroupInput, buttonInput, chipInput, fileInput, formInput, groupInput, listGroupInput, menuInput, navInput, radioInput, rangeInput, selectInput, sliderInput, textInput

Examples

Run this code
# NOT RUN {
### One option

checkboxInput(
  id = "checkbox1",
  choices = "Choice 1",
  selected = "Choice 1"
)

### Multiple options

checkboxInput(
  id = "checkbox2",
  choices = c("Choice 1", "Choice 2")
)

### Inline checkbox

checkboxInput(
  id = "checkbox3",
  choices = c("Choice 1", "Choice 2", "Choice 3"),
  inline = TRUE
)

### Checkbar

checkbarInput(
  id = "checks",
  choices = c(
    "Check 1",
    "Check 2",
    "Check 3"
  ),
  selected = "Check 1"
) %>%
  background("blue") %>%
  margin(2)

### Labeling a checkbar

formGroup(
  label = "Toppings",
  checkbarInput(
    id = "fixins",
    choices = c(
      "Sprinkles",
      "Nuts",
      "Fudge"
    )
  )
)

### Switches

switchInput(
  id = "switch1",
  choices = paste("Switch choice", 1:3),
  selected = "Switch choice 3"
) %>%
  active("indigo")

# }

Run the code above in your browser using DataLab