更改 Shinydashboard selectInput 文本的文本颜色
Change text colour of Shiny Dashbaord selectInput text
我已经构建了一个 Shiny Dashboard,并希望更改我的 selectInput 文本的文本颜色。例如,在下面的代码中,我想将文本 'Passing Metric' 和 'Game location' 的颜色更改为黑色而不是白色。我已经尝试了一些事情,但到目前为止还没有解决方案,我们将不胜感激。
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 以了解更多相关信息。
我已经构建了一个 Shiny Dashboard,并希望更改我的 selectInput 文本的文本颜色。例如,在下面的代码中,我想将文本 'Passing Metric' 和 'Game location' 的颜色更改为黑色而不是白色。我已经尝试了一些事情,但到目前为止还没有解决方案,我们将不胜感激。
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 以了解更多相关信息。