2017-04-19 64 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