我正在开发一个Shiny的互动应用程序。作为界面的一部分,我想使inputPanel颜色成为一种令人愉快的绿色。但是当我使用style = background-color: #EFF8CD"
时,只有inputPanel的内部会改变颜色,在外面留下灰色边框。下面是一些重现问题的代码,使用一组不同的颜色来显示更好的对比度:
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(style = "background-color: #E1AAAA",
inputPanel(style = "background-color: #EFF811",
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
我包含显示行为的生成应用的图片。有没有办法改变inputPanel的所有颜色,或者这只是包的特质? Image of example app showing grey border around inputPanel
答案 0 :(得分:0)
您可以使用以下css
删除灰色边框:
tags$head(tags$style(type = 'text/css',".shiny-input-panel{padding: 0px 0px !important;}"))
在您的代码中,它将是这样的:
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
tags$head(tags$style(type = 'text/css',".shiny-input-panel{padding: 0px 0px !important;}")),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(style = "background-color: #E1AAAA",
inputPanel(style = "background-color: #EFF811",
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
希望它有所帮助!