我正在使用深色主题(闪亮主题中的石板)创建一个闪亮的应用程序。但是当我应用该主题时,我的 renderDataTable 输出存在两个问题:
- 应用程序背景太暗,看不到表格外的元素(显示 XX 条目、底部页码等)
- 表中的文字太浅,难以阅读。
对于问题#2,我尝试了 renderDataTable 领域中的选项,例如formatStyle()
,以及 css 选项,例如list(tags$head(tags$style("shipment.table span {color: #333333 ; background: #999999;}")))
但我对他们没有任何运气。我对闪亮、DT 和 css 很陌生,这可能与它有关...我尝试过的示例在下面的代码中注释掉了。
对于问题#1,我完全陷入困境。我不知道那些外部到表的元素叫什么,所以我没有运气找到可以尝试的东西!
library(shiny)
library(shinythemes)
library(DT)
d=as.data.frame(cbind(1:100,201:300))
ui<-fluidPage(
theme = shinytheme("slate"),
mainPanel(
DT::dataTableOutput('shipment.table')
#list(tags$head(tags$style("shipment.table span {color: #333333 ; background: #999999;}")))
#tags$head(tags$style("#shipment.table table {color: red;}"))
)
)
server<-function(input, output,session) {
output$shipment.table <- renderDataTable(d,filter = 'bottom',
options = list(lengthMenu = list(c(10,20,50,100,-1), c('10','20','50','100','All')),
pageLength = 10,autoWidth = TRUE),rownames=F) #%>% formatStyle(1,color="black")
}
shinyApp(ui=ui,server=server)
如果运行该应用程序,您将看到左上角带有“10”的下拉框,但该框前后应该有文本,因此显示“显示 10 个条目”。右下角还有一个 1,但应该还有其他几个页面可见(它们是,只是深色背景上的深色文本)。同样,表格文本在浅灰色/白色背景上呈浅灰色,难以阅读。谢谢你的帮助!