如何更改下方按钮的背景颜色。
以下是您可以运行的代码,您可以看到按钮背景仍为白色,但颜色为绿色
ui.r
library(shinydashboard)
dashboardPage(skin="black",
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th")),
menuItem(downloadButton('downloadData', label= 'Download', class= "mybutton"))
),
tags$head(tags$style(".mybutton{background-color:red;} .skin-black .sidebar .mybutton{color: green;}") )
),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
)
)
server.r
function(input, output,session) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$downloadData <- downloadHandler(
filename = function() {
paste("test", '.csv', sep='')
},
content = function(file) {
write.csv(c(1,2,3,4), file)
}
)
}
运行应用程序的代码
library(shiny)
runApp("C://Users/me/PathToProject")
这是返回的内容。你可以看到背景是白色但文字是绿色
答案 0 :(得分:0)
即使我遇到同样的问题。您可以尝试下面提到的代码,这肯定会对您有用:
downloadButton('downloadData', 'Download', class = "butt"),
tags$head(tags$style(".butt{background-color:#add8e6;} .butt{color: #337ab7;}"))