multiInput: Create a multiselect input control

Description Usage Arguments Value See Also Examples

View source: R/input-multi.R

Description

A user-friendly replacement for select boxes with the multiple attribute

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
multiInput(
  inputId,
  label,
  choices = NULL,
  selected = NULL,
  options = NULL,
  width = NULL,
  choiceNames = NULL,
  choiceValues = NULL
)

Arguments

inputId

The input slot that will be used to access the value.

label

Display label for the control, or NULL for no label.

choices

List of values to select from.

selected

The initially selected value.

options

List of options passed to multi (enable_search = FALSE for disabling the search bar for example).

width

The width of the input, e.g. 400px, or 100%.

choiceNames

List of names to display to the user.

choiceValues

List of values corresponding to choiceNames.

Value

A multiselect control

See Also

updateMultiInput to update value server-side.

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Only run examples in interactive R sessions
if (interactive()) {

library("shiny")
library("shinyWidgets")


# simple use

ui <- fluidPage(
  multiInput(
    inputId = "id", label = "Fruits :",
    choices = c("Banana", "Blueberry", "Cherry",
                "Coconut", "Grapefruit", "Kiwi",
                "Lemon", "Lime", "Mango", "Orange",
                "Papaya"),
    selected = "Banana", width = "350px"
  ),
  verbatimTextOutput(outputId = "res")
)

server <- function(input, output, session) {
  output$res <- renderPrint({
    input$id
  })
}

shinyApp(ui = ui, server = server)


# with options

ui <- fluidPage(
  multiInput(
    inputId = "id", label = "Fruits :",
    choices = c("Banana", "Blueberry", "Cherry",
                "Coconut", "Grapefruit", "Kiwi",
                "Lemon", "Lime", "Mango", "Orange",
                "Papaya"),
    selected = "Banana", width = "400px",
    options = list(
      enable_search = FALSE,
      non_selected_header = "Choose between:",
      selected_header = "You have selected:"
    )
  ),
  verbatimTextOutput(outputId = "res")
)

server <- function(input, output, session) {
  output$res <- renderPrint({
    input$id
  })
}

shinyApp(ui = ui, server = server)

}

Example output



shinyWidgets documentation built on Sept. 17, 2021, 5:06 p.m.