I would like to change the colour of each individual option of the selectizeInput
menu in my Shiny app. In the following example code below I am able to change
Replacing my code with the above suggested code changed the drop down menu colour but NOT the individual items in the menu:
shinyApp(
ui =
shinyUI(fluidPage(
tags$head(
tags$style(HTML("
.option[data-value=a] {
background: red !important;
color: white !important;
}
.option[data-value=b] {
background: green !important;
color: white !important;
}
"))
),
sidebarLayout(
sidebarPanel(
selectizeInput("select", label=NULL,
choices=c("a", "b"),
selected = c("a", "b"),
multiple=TRUE, options=list(placeholder="Wybierz"))),
mainPanel())
)
),
server = function(input, output){}
)
SOLUTION In order to achieve both items colour coded and the drop down. I needed to add .item
to my code
shinyApp(
ui =
shinyUI(fluidPage(
tags$head(
tags$style(HTML("
.option[data-value=a], .item[data-value=a]{
background: red !important;
color: white !important;
}
.option[data-value=b], .item[data-value=b]{
background: green !important;
color: white !important;
}
"))
),
sidebarLayout(
sidebarPanel(
selectizeInput("select", label=NULL,
choices=c("a", "b"),
selected = c("a", "b"),
multiple=TRUE, options=list(placeholder="Wybierz"))),
mainPanel())
)
),
server = function(input, output){}
)
This results in both the menu and drop down menu being coloured.
You can do:
.option[data-value=a] {
background: red !important;
color: white !important;
}
.option[data-value=b] {
background: green !important;
color: white !important;
}
.option[data-value=c] {
background: blue !important;
color: white !important;
}
.option[data-value=d] {
background: magenta !important;
color: white !important;
}