adapted from:
library(shiny)
library(stringi)
t1 <- tibble(choices = stringi::stri_rand_strings(200, 5),
group = stri_rand_strings(200, 1, pattern = "[AB]")) %>%
mutate(html=ifelse(group=='A',paste0("<span style='color:red';>",choices,"</span>"),
paste0("<span style='color:blue';>",choices,"</span>")
))
items <- setNames(t1$choices, t1$html)
runApp(shinyApp(
ui = fluidPage(
selectizeInput("id", "Label", choices = items,
options = list(render = I("
{
item: function(item, escape) { return '<div>' + item.label + '</div>'; },
option: function(item, escape) { return '<div>' + item.label + '</div>'; }
}")))
),
server = function(input, output, session) {
}
))