选择器输入字体或背景颜色

Gib*_*999 1 r shiny

我在闪亮的仪表板中使用了 pickerInput,这很好,除了一个问题:背景颜色和字体颜色太相似,使过滤器选择难以阅读。

在此处输入图片说明

有没有办法改变背景或字体颜色?如果可能的话,我想继续使用 pickerInput,但如果有一个带有 selectInput 的方法或其他任何东西都可以。

在屏幕截图中产生结果的我的选择器输入之一的示例:

output$typeOutput80 <- renderUI({
  Commodity.Name <- as.vector( unique(DF2()$Commodity.Name) )
  pickerInput("typeOutput80", "Commodity:", 
     choices=Commodity.Name, Commodity.Name [1:10000], multiple=TRUE, 
     options = list(`actions-box` = TRUE, `live-search` = TRUE, 
                    `selected-text-format`= "static", title = "Commodity List")
  )
})`
Run Code Online (Sandbox Code Playgroud)

pha*_*man 5

这是一个有点hacky的解决方案,但它可能对你有用,或者至少让你走上正确的道路。

您可以使用choicesOptof 参数pickerInput来描述下拉菜单中各个选项的格式。在那里指定颜色、背景或重量会将相关元素更改为您选择的任何内容。诀窍是参数仅适用于第一个选择,因此您需要为尽可能多的选择复制样式参数。我已经这样做了,rep()并且我只是在那里添加了一个值 (10) 来匹配choices,但您可能希望根据商品清单数据的来源以编程方式定义该值。

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  pickerInput("id", "Formatting changes", multiple=T, choices = sample(LETTERS, size = 10), 
              options = list(`actions-box` = TRUE, `live-search` = TRUE, 
                         `selected-text-format`= "static", title = "Commodity List"),
              choicesOpt = list(
                style = rep(("color: black; background: lightgrey; font-weight: bold;"),10)))
)

server <- function(input, output){}

shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)