Mr3*_*369 3 html javascript css r shiny
我希望我的Shiny select输入能够:
#2f2d57但是,我无法使该应用程序一起遵守上述4条规则。我的代码如下:
数据:
table <- data.frame(col1 = c(3, 4, 8, 5, 2, 6, 7))
Run Code Online (Sandbox Code Playgroud)
尝试1
问题:用户无法键入内容并从selectInput中进行选择
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style("#three_code_zip_selector {color: #ffffff; background-color: #2f2d57;}"),
selectInput('three_code_zip_selector', NULL, choices = c("Please Select Desired Number" = "", table$col1), selectize = F)
)
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
尝试2
问题:通过删除selectize = F,用户可以键入选择,但是背景颜色没有更改。
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style("#three_code_zip_selector {color: #ffffff; background-color: #2f2d57;}"),
selectInput('three_code_zip_selector', NULL, choices = c("Please Select Desired Number" = "", table$col1))
)
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
我也在尝试selectizeInput,但似乎仍然存在与上面相同的问题。
尝试3
问题:用户可以键入,但是背景颜色没有更改,并且selectizeInput的顶部有一个我不想要的标签。
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style(".selectize-dropdown-content .active {background: #2f2d57; !important;color: #ffffff; !important;}"),
selectizeInput('three_code_zip_selector', "s", choices = c("Please Select Desired Number" = "", table$col1))
)
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
有人对我如何能够满足所有这四个规则有想法吗?提前致谢!
这是一个纯粹的闪亮解决方案:
library(shiny)
table <- data.frame(col1 = c(3, 4, 8, 5, 2, 6, 7))
ui <- fluidPage(
tags$head(tags$style(HTML('
#three_code_zip_selector+ div>.selectize-dropdown{background: #2f2d57; color: #ffffff;}
#three_code_zip_selector+ div>.selectize-input{background: #2f2d57; color: #ffffff;}
'))),
selectizeInput(inputId = 'three_code_zip_selector', label = NULL, choices = table$col1, selected = NULL, multiple = TRUE, options = list('plugins' = list('remove_button'), placeholder = "Please Select Desired Number", 'create' = TRUE, 'persist' = TRUE)))
server <- function(input, output, session){}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)