Reputation: 823
I have the following code:
library(shiny)
# Remove all numbered colour names
col.list <- colours()[!grepl("\\d", colours())]
ui <- fluidPage(
selectInput(inputId = "col",
label = "Colour",
choices = col.list, selected = "maroon"),
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
It creates the following ui control:
It's a list of all R colours (excluding the numbered ones).
Is it possible to make it that each entry is coloured according to the actual colour, instead of all being black?
Upvotes: 1
Views: 478
Reputation: 29387
Maybe you can try shinyWidgets
package where you an style it inside the choicesOpt
. change the background
argument to color
if you want to change the color of the entries and not the background
library(shiny)
library(shinyWidgets)
col.list <- colours()[!grepl("\\d", colours())]
colors <- paste0("background:",col.list,";")
ui <- fluidPage(
pickerInput("col", "Colour", multiple=T, choices = col.list,
choicesOpt = list(
style = colors))
)
server <- function(input, output){}
shinyApp(ui, server)
Upvotes: 1