2017-04-19 67 views
0

这是this问题的后续问题。在前一个问题中,使用以下参数tags$head(tags$style(HTML("#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}")))从012端口更改为selectInput。现在我想更改服务器端特定选择输出的边框颜色。我的主要目标实际上是根据不同的条件改变颜色。要更改服务器端的颜色,我尝试了下面的代码,但它似乎不工作。有没有办法做到这一点?更改服务器端selectinput的边框颜色

这里是我试过的代码:

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) 

回答

1

你接近。

下面为一个运行的例子:

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) 
+0

谢谢。这正是我想要的。 – SBista