Debian Codegraph @

man/checkboxGroupInput.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/input-checkboxgroup.R
3 \name{checkboxGroupInput}
4 \alias{checkboxGroupInput}
5 \title{Checkbox Group Input Control}
6 \usage{
7 checkboxGroupInput(
8 inputId,
9 label,
10 choices = NULL,
11 selected = NULL,
12 inline = FALSE,
13 width = NULL,
14 choiceNames = NULL,
15 choiceValues = NULL
16 )
17 }
18 \arguments{
19 \item{inputId}{The \code{input} slot that will be used to access the value.}
20
21 \item{label}{Display label for the control, or \code{NULL} for no label.}
22
23 \item{choices}{List of values to show checkboxes for. If elements of the list
24 are named then that name rather than the value is displayed to the user. If
25 this argument is provided, then \code{choiceNames} and \code{choiceValues}
26 must not be provided, and vice-versa. The values should be strings; other
27 types (such as logicals and numbers) will be coerced to strings.}
28
29 \item{selected}{The values that should be initially selected, if any.}
30
31 \item{inline}{If \code{TRUE}, render the choices inline (i.e. horizontally)}
32
33 \item{width}{The width of the input, e.g. \code{'400px'}, or \code{'100\%'};
34 see \code{\link[=validateCssUnit]{validateCssUnit()}}.}
35
36 \item{choiceNames, choiceValues}{List of names and values, respectively,
37 that are displayed to the user in the app and correspond to the each
38 choice (for this reason, \code{choiceNames} and \code{choiceValues}
39 must have the same length). If either of these arguments is
40 provided, then the other \emph{must} be provided and \code{choices}
41 \emph{must not} be provided. The advantage of using both of these over
42 a named list for \code{choices} is that \code{choiceNames} allows any
43 type of UI object to be passed through (tag objects, icons, HTML code,
44 ...), instead of just simple text. See Examples.}
45 }
46 \value{
47 A list of HTML elements that can be added to a UI definition.
48 }
49 \description{
50 Create a group of checkboxes that can be used to toggle multiple choices
51 independently. The server will receive the input as a character vector of the
52 selected values.
53 }
54 \section{Server value}{
55
56 Character vector of values corresponding to the boxes that are checked.
57 }
58
59 \examples{
60 ## Only run examples in interactive R sessions
61 if (interactive()) {
62
63 ui <- fluidPage(
64 checkboxGroupInput("variable", "Variables to show:",
65 c("Cylinders" = "cyl",
66 "Transmission" = "am",
67 "Gears" = "gear")),
68 tableOutput("data")
69 )
70
71 server <- function(input, output, session) {
72 output$data <- renderTable({
73 mtcars[, c("mpg", input$variable), drop = FALSE]
74 }, rownames = TRUE)
75 }
76
77 shinyApp(ui, server)
78
79 ui <- fluidPage(
80 checkboxGroupInput("icons", "Choose icons:",
81 choiceNames =
82 list(icon("calendar"), icon("bed"),
83 icon("cog"), icon("bug")),
84 choiceValues =
85 list("calendar", "bed", "cog", "bug")
86 ),
87 textOutput("txt")
88 )
89
90 server <- function(input, output, session) {
91 output$txt <- renderText({
92 icons <- paste(input$icons, collapse = ", ")
93 paste("You chose", icons)
94 })
95 }
96
97 shinyApp(ui, server)
98 }
99 }
100 \seealso{
101 \code{\link[=checkboxInput]{checkboxInput()}}, \code{\link[=updateCheckboxGroupInput]{updateCheckboxGroupInput()}}
102
103 Other input elements:
104 \code{\link{actionButton}()},
105 \code{\link{checkboxInput}()},
106 \code{\link{dateInput}()},
107 \code{\link{dateRangeInput}()},
108 \code{\link{fileInput}()},
109 \code{\link{numericInput}()},
110 \code{\link{passwordInput}()},
111 \code{\link{radioButtons}()},
112 \code{\link{selectInput}()},
113 \code{\link{sliderInput}()},
114 \code{\link{submitButton}()},
115 \code{\link{textAreaInput}()},
116 \code{\link{textInput}()},
117 \code{\link{varSelectInput}()}
118 }
119 \concept{input elements}