I want to color elements according to their index number in R Shiny (first match blue, second yellow, third red).
Reproducible example:
library(shiny)
ui <- fluidPage(
tags$style(".control-label:nth-of-type(1) {background-color:blue;}"),
tags$style(".control-label:nth-of-type(2) {background-color:yellow;}"),
tags$style(".control-label:nth-of-type(3) {background-color:red;}"),
lapply(
letters[1:3],
FUN = function(name){
selectizeInput(
inputId = paste0("type_", name),
label = paste0(name),
choices = "a",
selected = "a",
multiple = TRUE,
options = list(create = TRUE)
)
}
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
What i tried:
According to: CSS selector for first element with class i see a few Options:
- overwriting with the first match with the (~) Operator, but how would i do that for the second and third element then?
:nth-of-type(1)
-> i cant get that running, see example above.