我建立了一个Shiny Dashboard,并希望更改我的selectInput文本的文本颜色。例如,在下面的代码中,我想将文本“通过度量”和“游戏位置”的颜色更改为黑色,而不是白色。到目前为止,我已经尝试了一些方法,但是没有解决方案,我们将不胜感激。
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)
您可以将CSS代码添加到您的应用中,请使用tags$style("label{color: black;}")
执行此操作。
以下是可重现的示例:
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)
阅读documentation,以了解更多有关此的信息。