Learn R Programming

shinySelect (version 1.3.0)

HTMLgroupedChoices: Choices with groups and HTML

Description

Create an object for grouped choices resorting to HTML.

Usage

HTMLgroupedChoices(groups, labels, values)

Value

An object to be passed on to the choices argument of the

selectControlInput function.

Arguments

groups

list of HTML elements which can be created with the HTML function or shiny.tag objects, the headings

labels

list of lists, one list for each group, made of HTML elements

values

list of lists of character strings, each label must have a value

Examples

Run this code
library(shinySelect)
library(shiny)
states <- HTMLgroupedChoices(
  groups = lapply(list("East Coast", "West Coast", "Midwest"), function(x){
    tags$h2(x, style="text-decoration: underline")
  }),
  labels = list(
    lapply(list("NY", "NJ", "CT"), function(x){
      tags$span(HTML("•"), x, style="color: red")
    }),
    lapply(list("WA", "OR", "CA"), function(x){
      tags$span(HTML("•"), x, style="color: green")
    }),
    lapply(list("MN", "WI", "IA"), function(x){
      tags$span(HTML("•"), x, style="color: blue")
    })
  ),
  values = list(
    list("NY", "NJ", "CT"),
    list("WA", "OR", "CA"),
    list("MN", "WI", "IA")
  )
)

Run the code above in your browser using DataLab