如何从pickerInput包中更改shinyWidgets包中标签的颜色?我想把“产品”的颜色改为“白色”。我只找到了如何改变背景颜色和其他文本的颜色。当我希望代码也改变其他输入小部件的标签时,我必须在哪里将这些更改包括到代码中?
library(shiny)
library(shinyWidgets)
library(bs4Dash)
ui <- dashboardPage(
dashboardHeader(title = "TEST",
fixed= TRUE,
disable = TRUE),
dashboardSidebar(
sidebarMenu(
menuItem(
"A1",
tabName = "a1"
),
menuItem(
text = "Analyse",
tabName = "analyse",
pickerInput(
inputId = "product",
label = "Product",
choices = c("hjk", "cgh", "ölk", "cfh"),
options = list(title = "choose here")
),
startExpanded = TRUE
)
)
),
dashboardBody()
)
## Server-function -----
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)
发布于 2022-11-08 10:40:51
您可以将标签包装在div
中以实现以下目的:
library(shiny)
library(shinyWidgets)
library(bs4Dash)
ui <- dashboardPage(
dashboardHeader(
title = "TEST",
fixed = TRUE,
disable = TRUE
),
dashboardSidebar(sidebarMenu(
menuItem("A1", tabName = "a1"),
menuItem(
text = "Analyse",
tabName = "analyse",
pickerInput(
inputId = "product",
label = div("Product", style = "color: white;"),
choices = c("hjk", "cgh", "ölk", "cfh"),
options = list(title = "choose here")
),
startExpanded = TRUE
)
)),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
如果您想将此应用于所有pickerInput
,我们可以使用JS并查找类control-label
。
library(shiny)
library(shinyWidgets)
library(bs4Dash)
ui <- dashboardPage(
dashboardHeader(
title = "TEST",
fixed = TRUE,
disable = TRUE
),
dashboardSidebar(sidebarMenu(
menuItem("A1", tabName = "a1"),
menuItem(
text = "Analyse",
tabName = "analyse",
pickerInput(
inputId = "product",
label = "Product",
choices = c("hjk", "cgh", "ölk", "cfh"),
options = list(title = "choose here")
),
pickerInput(
inputId = "something",
label = "Something else ",
choices = c("hjk", "cgh", "ölk", "cfh"),
options = list(title = "choose here")
),
startExpanded = TRUE
)
)),
dashboardBody(tags$script(
HTML("[...document.getElementsByClassName('control-label')].forEach((el)=>{el.style.color = 'white';});"
)
))
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
请参阅这相关的答案。
此外,您可能需要检查库(鲜食)。
https://stackoverflow.com/questions/74357701
复制相似问题