RanonKahn
RanonKahn

Reputation: 862

How to change R Shiny 'selectInput' value selection display space background color when no value selected?

I wish to visually alert users when a selectInput() value has not been selected as shown below. Could not locate a solution in this forum except for this but the ask is different.

enter image description here

Upvotes: 0

Views: 407

Answers (1)

YBS
YBS

Reputation: 21297

Some of the controls are in the css below

library(shiny)

css <- "
.selectize-dropdown-content .option {
  color: blue;
}
.selectize-input .item {
  color: red !important;
  background-color: yellow !important;
}
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  background-color:red !important;
  color: white;
}
::-moz-placeholder { /* Firefox 19+ */
  color: pink;
}
:-ms-input-placeholder { /* IE 10+ */
  color: pink;
}
:-moz-placeholder { /* Firefox 18- */
  color: pink;
}"

ui <- fluidPage(
  tags$head(
    tags$style(HTML(css))
  ),
  br(),
  selectInput("my_select", "Choose: ", c("Please choose a site or say anything"='',"Site 1", "Site 2","Site 3", "Site 4"), 
              selectize = T),
  br()
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

output

Upvotes: 2

Related Questions