[英]Changing the colour of selectInput entries in Shiny R
I have the following code:我有以下代码:
library(shiny)
# Remove all numbered colour names
col.list <- colours()[!grepl("\\d", colours())]
ui <- fluidPage(
selectInput(inputId = "col",
label = "Colour",
choices = col.list, selected = "maroon"),
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
It creates the following ui control:它创建以下 ui 控件:
It's a list of all R colours (excluding the numbered ones).这是所有 R 颜色的列表(不包括编号的颜色)。
Is it possible to make it that each entry is coloured according to the actual colour, instead of all being black?是否可以根据实际颜色对每个条目进行着色,而不是全部为黑色?
Maybe you can try shinyWidgets
package where you an style it inside the choicesOpt
.也许您可以尝试
shinyWidgets
package ,您可以在choicesOpt
中设置样式。 change the background
argument to color
if you want to change the color of the entries and not the background如果要更改条目的颜色而不是背景,请将
background
参数更改为color
library(shiny)
library(shinyWidgets)
col.list <- colours()[!grepl("\\d", colours())]
colors <- paste0("background:",col.list,";")
ui <- fluidPage(
pickerInput("col", "Colour", multiple=T, choices = col.list,
choicesOpt = list(
style = colors))
)
server <- function(input, output){}
shinyApp(ui, server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.