title: Shiny - Change background-color of htmlOutput conditionally
body: <p>I have a shiny-app which is displaying name of a District through <code>htmlOutput</code>. Now these districts have a corresponding category - A/B/C, and based on whether category==A,B,C I want to set background-color of htmlOutput to 'red','blue','green'.</p>
  
  <p>I don't know how to conditionally change background-color. I'm fairly new to CSS. </p>
  
  <p>So far, I've been able to set the background-color but not change it by using the code below in ui.R (where dist is the tag used for htmlOutput displaying district):</p>
  
  <pre><code>HTML('
            #dist{
                        background-color: rgba(255,0,255,0.9);
            }
      ')
  </code></pre>
  
  <p>Reproducible example below:</p>
  
  <pre><code>library(shiny)
  
  
  ui &lt;- fluidPage(
     titlePanel("Test App"),
  
     selectInput("yours", choices = c("India", "Malaysia","Russia","Poland", "Hungary"), label = "Select Country:"),
    absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE, 
                  style="padding-left: 8px; padding-right: 8px; padding-top: 8px; padding-bottom: 8px",
                  draggable = TRUE, top = 126, left = "auto", right = 20, bottom = "auto",
                  width = 250, height = "auto",
       htmlOutput("sel"), br(),htmlOutput("sel2")
     )
  )
  
  server &lt;- function(input, output){
    catg&lt;- c("A","A","B","C","A")
    country &lt;- c("India", "Malaysia","Russia","Poland", "Hungary")
    countries &lt;- data.frame(catg,country)
  
    output$sel &lt;- renderText({
      paste0("Change my background color and of the text to my right based on variable catg:",input$yours,"-", countries$catg[countries$country==input$yours])
    })
  
    output$sel2 &lt;- renderText({
      paste0("DON'T change my background color:", countries$catg[countries$country==input$yours])
    })
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Here we have two output variables - sel, sel2
  I want to change background-color of sel based on variable "catg", i.e. give #sel background-color:red if catg=="A", background-color:blue; if catg=="B", etc. </p>