我有一个简单的闪亮应用程序,我想在其中使用 javascript 将我的 selectInput() 的背景颜色从白色更改为橙色。是否有可能?我应该把callback
论点放在哪里?
#ui.r
library(shiny)
ui <- fluidPage(
theme=shinytheme("slate") ,
# App title ----
titlePanel(uiOutput("title")),
#This hides the temporary warning messages while the plots are being created
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
# Sidebar layout with input and output definitions ----
sidebarLayout(
uiOutput("menu"),
# Main panel for displaying outputs ----
mainPanel(
)
)
)
#server.r
server = function(input, output) {
output$menu<-renderUI({
sidebarPanel(width = 2,
selectInput("sel","",
choices = c("Home","About","Sector A","Sector B","Sector C"),
selected = "Home"),
tags$style(
"select#sel {background: #FFA500}"
)
)
})
}
如果你把它应该工作selectize = FALSE
。
默认情况下,selectInput
有selectize = TRUE
它使用selectize.js。
因此,如果您按原样运行代码,那么您应该会看到您的选择显示为 display: none
所以你output$menu
会像
output$menu<-renderUI({
sidebarPanel(width = 2,
selectInput("sel","",
choices = c("Home","About","Sector A","Sector B","Sector C"),
selected = "Home", selectize = FALSE),
tags$style(
"select#sel {background: #FFA500}"
)
)
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句