Css 更改选取器的颜色将项目放入有光泽的
有人能告诉我是否可能,以及如何从Css 更改选取器的颜色将项目放入有光泽的,css,r,shiny,Css,R,Shiny,有人能告诉我是否可能,以及如何从shinyWidgets软件包中更改pickerInputUI下拉菜单中项目的字体颜色吗 下面是小部件的一个简短示例: 库(“闪亮”) 图书馆(“shinyWidgets”) shinyApp( 用户界面= shinyUI(fluidPage)( 侧边栏布局( 侧栏面板( pickerInput(“选择”,标签=NULL, 选择=字母, 选定=字母, 倍数=真, 选项=列表( `操作框`=TRUE, 尺寸=10, `所选文本格式“=”计数>3” )) ), 主面板
shinyWidgets
软件包中更改pickerInput
UI下拉菜单中项目的字体颜色吗
下面是小部件的一个简短示例:
库(“闪亮”)
图书馆(“shinyWidgets”)
shinyApp(
用户界面=
shinyUI(fluidPage)(
侧边栏布局(
侧栏面板(
pickerInput(“选择”,标签=NULL,
选择=字母,
选定=字母,
倍数=真,
选项=列表(
`操作框`=TRUE,
尺寸=10,
`所选文本格式“=”计数>3”
))
),
主面板())
)
),
服务器=函数(输入、输出){}
)
>sessionInfo()
R版本4.0.0(2020-04-24)
平台:x86_64-apple-darwin17.0(64位)
运行条件:macOS High Sierra 10.13.6
矩阵乘积:默认值
BLAS:/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK:/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
区域设置:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
附加基本包:
[1] stats4并行统计数据图形设备GRUTILS数据集方法库
其他随附包裹:
[1] shinyWidgets_0.5.3 Dendestend_1.13.4 tidyr_1.1.0拼凑_1.0.1 ggplot2_3.3.1
[6] shinyhelper_0.3.2色彩空间_1.4-1色彩选择器_1.0 shinythemes_1.1.2 DT_0.13
[11] dplyr_1.0.0_1.4.0.2 MSnbase_2.14.2原型_1.20.0 S4Vectors_0.26.1
[16] mzR_2.22.0 Rcpp_1.0.4.6 Biobase_2.48.0 BioGenerics_0.34.0
尝试添加
tags$head(
tags$style(HTML("
.dropdown-menu a{
color: red !important;
}
"))
这就是你要找的吗
ui =
shinyUI(fluidPage(tags$head(
tags$style(HTML("
.dropdown-menu a{
color: red !important;
}
"))
),
sidebarLayout(
sidebarPanel(
pickerInput("select", label=NULL,
choices=LETTERS,
selected = LETTERS,
multiple=TRUE,
options = list(
`actions-box` = TRUE,
size = 10,
`selected-text-format` = "count > 3"
))
),
mainPanel())
)
)
server = function(input, output){}
shinyApp(ui, server)
可以在其参数中应用所需的样式:
library(shiny)
library(shinyWidgets)
col.list <- c("red","blue","green","orange")
# Change the color
colors <- paste0("color:",col.list,";")
# Change the font
colors <- paste0(colors,"font-family: Arial;")
# Change to bold
colors <- paste0(colors,"font-weight: bold;")
ui <- fluidPage(
pickerInput("col", "Colour", multiple=T, choices = col.list,
choicesOpt = list(
style = colors)
)
)
server <- function(input, output){}
shinyApp(ui, server)
要动态使用颜色,可以执行以下操作:
library(shiny)
library(shinyWidgets)
col.list <- c("red","blue","green","orange")
ui <- fluidPage(
column(2,
pickerInput("change", "Select Colour", choices = col.list,multiple = FALSE)
),
column(2,
pickerInput("col", "Colour", multiple=T, choices = col.list)
)
)
server <- function(input, output,session){
observeEvent(input$change,{
colors <- rep(paste0("color:",input$change,";"),length(col.list))
updatePickerInput(session, "col", choices = col.list,
choicesOpt = list(
style = colors
)
)
})
}
shinyApp(ui, server)
库(闪亮)
图书馆(shinyWidgets)
col.list可以编辑答案,以明确如何对单个字母进行颜色编码。此示例仅显示如何将下拉菜单中的所有项目涂成相同颜色。非常感谢。这太棒了。我自己代码中的对象颜色
(不是这里的示例)是动态的,由用户从我的应用程序中的颜色选择器设置。因此,colors
是一个reactive
对象,我可以使用“renderUI”从服务器传递它,然后使用uiOutput(“colors”)
调用UI。这是行不通的。我可能需要问一个关于如何动态传递它的新问题。参见最后一个示例
library(shiny)
library(shinyWidgets)
col.list <- c("red","blue","green","orange")
ui <- fluidPage(
column(2,
pickerInput("change", "Select Colour", choices = col.list,multiple = FALSE)
),
column(2,
pickerInput("col", "Colour", multiple=T, choices = col.list)
)
)
server <- function(input, output,session){
observeEvent(input$change,{
colors <- rep(paste0("color:",input$change,";"),length(col.list))
updatePickerInput(session, "col", choices = col.list,
choicesOpt = list(
style = colors
)
)
})
}
shinyApp(ui, server)