javascript - 使用javascript更改R闪亮中selectinput的背景颜色
问题描述
我有一个简单的闪亮应用程序,我想使用 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}"
)
)
})
}
解决方案
根据您编辑的问题,您可能会使用 div 容器selectInput
div(
selectInput("sel","",
choices = c("Home","About","Sector A","Sector B","Sector C"),
selected = "Home"),
style = "background: #FFA500"
)
或者,如果您想为整个侧边栏面板设置样式,请设置样式form.well
sidebarPanel(
width = 2,
selectInput(
"sel","",
choices = c("Home","About","Sector A","Sector B","Sector C"),
selected = "Home"),
tags$style(
"form.well {background: #FFA500}"
)
)
推荐阅读
- javascript - 为转发构造函数提供 TypeScript 定义
- javascript - jQuery数据表正文行与头行不对齐
- python - 字典理解以创建偶数字典
- django - 键“(User_id) = (51)”已经存在
- spring - 使用spring-security时在docker中自动重新加载spring boot应用程序
- java - Camunda 部署具有全球可见性的代表
- c# - 如何访问当前开发服务器的控制器中的图像文件夹?
- python - 在 CrawlerProcess 中暂停单个蜘蛛
- javascript - 将进入/退出事件限制为仅 d3.js 中的背景 div
- ruby-on-rails - ApplicationController.renderer.render 无法在 Ruby on Rails 中找到部分内容