Shinydashboard 的下载按钮变灰了吗?
Shinydashboard grayed out downloadButton?
如何修复这个简单示例中的下载按钮?
library(shiny)
library(shinydashboard)
library(shinyjs)
header <- dashboardHeader()
sidebar <- dashboardSidebar(shinyjs::useShinyjs(),
actionButton("start_proc", "Click to make download button appear"),
p(),
downloadButton('data_file', 'Download'))
body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
observe({
if (input$start_proc > 0) {
Sys.sleep(1)
# enable the download button
shinyjs::show("data_file")
}
})
output$data_file <- downloadHandler(
filename = function() {
paste('data-', Sys.Date(), '.csv', sep='')
},
content = function(file) {
write.csv(data.frame(x=runif(5), y=rnorm(5)), file)
}
)
# disable the downdload button on page load
shinyjs::hide("data_file")
}
shinyApp(ui, server)
您放置在侧边栏中的任何下载按钮看起来都像那样(与它使用 hide/show 的事实无关)。如果您只是将按钮移动到主体而不是侧边栏,它看起来又正常了,如果您向侧边栏添加更多按钮,它们也会全部变灰。所以这告诉我们这可能与 CSS.
有关
如果您查看按钮的 CSS,您会看到规则
.skin-blue .sidebar a {
color: #b8c7ce;
}
所以它看起来像某人(闪亮的或 bootstrap,我不确定谁负责这个 CSS 文件)它故意制作 links(和下载按钮实际上只是一个样式不同的 link)灰色文本。所以你可以通过添加你自己的 CSS like
来解决这个问题
tags$style(".skin-blue .sidebar a { color: #444; }")
如何修复这个简单示例中的下载按钮?
library(shiny)
library(shinydashboard)
library(shinyjs)
header <- dashboardHeader()
sidebar <- dashboardSidebar(shinyjs::useShinyjs(),
actionButton("start_proc", "Click to make download button appear"),
p(),
downloadButton('data_file', 'Download'))
body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
observe({
if (input$start_proc > 0) {
Sys.sleep(1)
# enable the download button
shinyjs::show("data_file")
}
})
output$data_file <- downloadHandler(
filename = function() {
paste('data-', Sys.Date(), '.csv', sep='')
},
content = function(file) {
write.csv(data.frame(x=runif(5), y=rnorm(5)), file)
}
)
# disable the downdload button on page load
shinyjs::hide("data_file")
}
shinyApp(ui, server)
您放置在侧边栏中的任何下载按钮看起来都像那样(与它使用 hide/show 的事实无关)。如果您只是将按钮移动到主体而不是侧边栏,它看起来又正常了,如果您向侧边栏添加更多按钮,它们也会全部变灰。所以这告诉我们这可能与 CSS.
有关如果您查看按钮的 CSS,您会看到规则
.skin-blue .sidebar a {
color: #b8c7ce;
}
所以它看起来像某人(闪亮的或 bootstrap,我不确定谁负责这个 CSS 文件)它故意制作 links(和下载按钮实际上只是一个样式不同的 link)灰色文本。所以你可以通过添加你自己的 CSS like
来解决这个问题tags$style(".skin-blue .sidebar a { color: #444; }")