View source: R/input-checkbox.R
checkboxInput | R Documentation |
Reactive checkbox and checkbar inputs. Users may select one or more choices.
The checkbox input appears as a standard checkbox or set of checkboxes. When
a checkbox input has no selected choices the reactive value is NULL
. Switch
inputs differ from checkboxes only in appearance.
checkboxInput(
...,
id,
choices = NULL,
values = choices,
selected = NULL,
inline = FALSE
)
updateCheckboxInput(
id,
choices = NULL,
values = choices,
selected = NULL,
inline = FALSE,
enable = NULL,
disable = NULL,
valid = NULL,
invalid = NULL,
session = getDefaultReactiveDomain()
)
switchInput(..., id, choices, values = choices, selected = NULL)
updateSwitchInput(
id,
choices = NULL,
values = choices,
selected = NULL,
enable = NULL,
disable = NULL,
valid = NULL,
invalid = NULL,
session = getDefaultReactiveDomain()
)
... |
Additional named arguments passed as HTML attributes to the parent element or tag elements passed as child elements to the parent element. |
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 |
selected |
One or more of |
inline |
One of |
enable |
One of |
disable |
One of |
valid |
A character string specifying a message to the user indicating
how the input's value is valid, defaults to |
invalid |
A character string specifying a message to the user
indicating how the input's value is invalid, defaults to |
session |
A reactive context, defaults to |
Checkbox inputs may have a single possible value.
checkboxInput( id = NULL, choices = "Choice 1", selected = "Choice 1" )
You may also specify multiple possible values.
checkboxInput( id = NULL, choices = c("Choice 1", "Choice 2", "Choice 3"), selected = c("Choice 1", "Choice 2") )
While checkbox input choices are typically laid out vertically you can
lay out the choices horizontally with inline = TRUE
.
checkboxInput( id = NULL, choices = c("Choice 1", "Choice 2", "Choice 3"), inline = TRUE # <- )
The switch input functions identical to the checkbox input with a different appearance.
switchInput( id = NULL, choices = c("Toggle 1", "Toggle 2", "Toggle 3"), selected = "Toggle 2" )
Changing the background color of a checkbox or switch input will modify the background color of the selected choices.
checkboxInput( .style %>% background("warning"), id = NULL, choices = c("Choice 1", "Choice 2"), selected = c("Choice 1", "Choice 2") )
switchInput( .style %>% background("success"), id = NULL, choices = c("Toggle 1", "Toggle 2"), selected = "Toggle 1" )
formGroup( label = "Label", checkboxInput( id = NULL, choices = c("Choice 1", "Choice 2") ), help = "Help text for the input" )
Other inputs:
buttonGroupInput()
,
buttonInput()
,
checkbarInput()
,
chipInput()
,
fileInput()
,
formInput()
,
listGroupInput()
,
menuInput()
,
navInput()
,
radioInput()
,
radiobarInput()
,
rangeInput()
,
selectInput()
,
textInput()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.