Skip to content Skip to sidebar Skip to footer

How To Dynamically Style A Pickerinput Menu In Shiny

I would like to update the colours of my pickerInput based on input from the colourInput in the below example. This questions follows on from this question and replicating this wit

Solution 1:

CSS <- function(colors){
  template <- "
.dropdown-menu ul li:nth-child(%s) a {
  background: %s !important;
  color: white !important;
}"
  paste0(
    apply(cbind(seq_along(colors), colors), 1, function(vc){
      sprintf(template, vc[1], vc[2])
    }),
    collapse = "\n"
  )
}

and

output$css <- renderUI({
  tags$style(HTML(CSS(cols_user())))
})

To deal with CSS, you should try the inspector tool (right-click on an element, then "Inspect").

Post a Comment for "How To Dynamically Style A Pickerinput Menu In Shiny"