简体   繁体   English

更改 Shiny 仪表板的文本颜色选择输入文本

[英]Change text colour of Shiny Dashbaord selectInput text

I have built a Shiny Dashboard and am looking to change the text colour of my selectInput text.我已经构建了一个 Shiny 仪表板,并希望更改我的 selectInput 文本的文本颜色。 For example, in the below code, I want to change the colour of the text 'Passing Metric' and 'Game location' to BLACK instead of WHITE.例如,在下面的代码中,我想将文本“Passing Metric”和“Game location”的颜色更改为黑色而不是白色。 I've tried a few things but no solution so far, any help would be appreciated.我已经尝试了一些东西,但到目前为止还没有解决方案,任何帮助将不胜感激。

title = "Controls", solidHeader = TRUE, background = "maroon",width = 4,
                                    sidebarPanel(
                                      selectInput("select1", "Passing Metric:", 
                                                  choices = list("touchdown",
                                                                 "yards_gained",
                                                                 "third_down_converted"

                                                  )
                                      ),
                                      selectInput("select2", "Game location:",
                                                  choices = list("home",
                                                                 "away"))
                                      , width = 12)

You can add css code to your app, do this using tags$style("label{color: black;}") .您可以将 css 代码添加到您的应用程序中,使用tags$style("label{color: black;}")执行此操作。

Here a reproducible example:这是一个可重现的示例:

library(shiny)
library(shinydashboard)

tags$style("label{color: red;}")

ui <- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(
        tags$style("label{color: black;}"),
        selectInput(inputId = "selecet1", label = "Passing Mectric",
                    choices = c("Touch down", "yards"))
        ),
    dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

Read the documentation in order to learn more about this.阅读文档以了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM