闪亮的数据表如何更改主题

4
我想在一个shiny应用程序中应用暗色主题:
    library(shinythemes)

    shinyUI(fluidPage(
      theme = shinytheme("cyborg"),
     ...)

但是 DT 数据表格没有遵循主题颜色。

我该如何使其变为暗色调?

非常感谢。


4
我认为你应该将DT切换为Bootstrap样式,这样CSS样式也可以应用于表格中。在你的DT调用中使用style='bootstrap' - Valter Beaković
好的,谢谢,现在我明白了。下载并复制bootstrap.css到目录中,使用style='bootstrap'调用DT。谢谢。 - Kelvin Cambridge
只需在数据表调用中将样式设置为Bootstrap,其余部分已经准备就绪。 - Valter Beaković
1个回答

11

除了您发布的代码外,您还必须向您的datatable函数添加以下参数。下面是完全可重现的代码。

library(shiny)
library(DT)
library(shinythemes)

ui <- fluidPage(
  theme = shinytheme("cyborg"),
  mainPanel(
    DTOutput("table")
  )
)

server <- function(input, output){
    output$table <- renderDT({
      datatable(iris,
                style = "bootstrap" # <--------- This is the crucial part
      )
    })
}

# Create Shiny app ----
shinyApp(ui, server)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接