0

I would like to create a checkbox input organized by continents and inside each continent the clickable options would be the countries.

I need to use this checkbox with pickerinput option from shinyWidgets package.

This is what I tried but its not working

    pickerInput(
           inputId = "Id008",
           label = "With plain HTML",
           choices = list(`Africa` = list("NY", "NJ", "CT"),
                                   `Americas` = list("WA", "OR", "CA"),
                                   `Asia` = list("MN2", "W2I", "I2A"),
                                   `Europe` = list("3MN", "3WI", "I3A"),
                                   `Oceania` = list("M4N", "W4I", "I4A")
                              ),
            multiple = TRUE,
            selected = 
            )
Laura
  • 675
  • 10
  • 32

1 Answers1

2

From the description of what you are trying to achieve I think you are looking for shinyWidgets::virtualSelectInput which allows to group options:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  virtualSelectInput(
    inputId = "Id008",
    label = "With plain HTML",
    choices = list(
      `Africa` = list("NY", "NJ", "CT"),
      `Americas` = list("WA", "OR", "CA"),
      `Asia` = list("MN2", "W2I", "I2A"),
      `Europe` = list("3MN", "3WI", "I3A"),
      `Oceania` = list("M4N", "W4I", "I4A")
    ),
    multiple = TRUE,
    disableOptionGroupCheckbox = TRUE
  )
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

enter image description here

stefan
  • 90,330
  • 6
  • 25
  • 51