Reputation: 7694
This is a followup question to this question. In the previous question the border of selectInput
was changed from the ui side using the following argument tags$head(tags$style(HTML( "#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}")))
. Now I would like to change the border colour of a particular select output from the server side. My main aim is actually to change the colour based of different conditions. To change the colour from the server side I tried the following code but it does not seem to work. Is there a way to achieve this?
Here is the code I tried:
library(shiny)
ui <- fluidPage(
tags$head(tags$style(htmlOutput("Border_Arg"))),
selectInput("Select1", "Option1", choices = NULL),
selectInput("Select2", "Option2", choices = NULL)
)
server <- function(input, output){
output$Border_Arg <- renderUI({"#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}"})
}
shinyApp(ui = ui, server = server)
Upvotes: 0
Views: 402
Reputation: 17689
You were close.
Find a running example below:
library(shiny)
ui <- fluidPage(
selectInput("Select1", "Option1", choices = NULL),
selectInput("Select2", "Option2", choices = NULL),
uiOutput("Border_Arg")
)
server <- function(input, output){
output$Border_Arg <- renderUI({
tags$head(tags$style(HTML( "#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}")))
})
}
shinyApp(ui = ui, server = server)
Upvotes: 1