我想更改我的应用程序中selectizeInput
菜单的每个选项的颜色。在下面的示例代码中,我可以将所有菜单选项的颜色更改为蓝色,但如何更改每个选项的颜色?例如,使"a"为红色,"b"为蓝色,"c"为绿色等。
非常感谢!
shinyApp(
ui =
shinyUI(fluidPage(
tags$head(
tags$style(HTML("
.item {
background: #2196f3 !important;
color: white !important;
}
.selectize-dropdown-content .active {
background: #2196f3 !important;
color: white !important;
}
"))
),
sidebarLayout(
sidebarPanel(
selectizeInput("select", label=NULL,
choices=c("a", "b", "c", "d"),
selected = c("a", "b", "c", "d"),
multiple=TRUE, options=list(placeholder="Wybierz"))),
mainPanel())
)
),
server = function(input, output){}
)
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods
[9] base
other attached packages:
[1] rsconnect_0.8.16 shinythemes_1.1.2 dplyr_0.8.5 shiny_1.4.0.2
[5] BiocParallel_1.20.1 MLInterfaces_1.66.5 cluster_2.1.0 annotate_1.64.0
[9] XML_3.99-0.3 AnnotationDbi_1.48.0 IRanges_2.20.2 MSnbase_2.12.0
[13] ProtGenerics_1.18.0 S4Vectors_0.24.4 mzR_2.20.0 Rcpp_1.0.4.6
[17] Biobase_2.46.0 BiocGenerics_0.32.0
3条答案
按热度按时间pokxtpni1#
用上面建议的代码替换我的代码改变了下拉菜单的颜色,但没有菜单中的单个项目:
解决方案为了实现项目颜色编码和下拉。我需要添加
.item
到我的代码第一节第二节第一节第三节第一节
这会导致菜单和下拉菜单都被着色。
thtygnil2#
您可以:
6jjcrrmo3#
更灵活的方法。不用在css中为a和b编码颜色。
从https://community.rstudio.com/t/selectinput-conditional-formatting/81563/2复制