如何更改來自 shinyWidgets 包的 pickerInput 中標簽的顏色?我想將“產品”的顏色更改為“白色”。我只發現了如何更改背景顏色和其他文本的顏色。當我希望代碼更改最終將包含的其他輸入小部件的標簽時,我必須在哪里將更改包含到代碼中?
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)
uj5u.com熱心網友回復:
您可以將標簽包裝在 adiv中以實作此目的:
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)
如果您想將此應用于所有pickerInputs 我們可以使用 JS 并查找 class 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://www.uj5u.com/caozuo/529438.html
標籤:r闪亮的闪亮的小工具
下一篇:如何將序數變數轉換為二進制變數
