【问题标题】:Shiny datatable how to change theme闪亮的数据表如何更改主题
【发布时间】:2017-04-29 12:06:56
【问题描述】:

我想将深色主题应用于闪亮的应用程序:

    library(shinythemes)

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

但 DT 数据表不遵循主题颜色。

我怎样才能让它变暗?

非常感谢。

【问题讨论】:

  • 我认为您应该将 DT 切换为引导样式,以便将 css 也应用于表格。在您的 DT 通话中使用 style = 'bootstrap'。
  • 好的,谢谢,现在我明白了。下载 bootstrap.css 并将其复制到该目录,并使用 style = 'bootstrap' 调用 DT。谢谢
  • 只需在datable调用中将样式设置为bootstrap,其余的都已经存在了。

标签: r shiny themes dt


【解决方案1】:

除了您发布的代码之外,您还必须将以下参数添加到您的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)

【讨论】:

    猜你喜欢
    • 2019-06-21
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 1970-01-01
    • 2017-06-06
    • 1970-01-01
    相关资源
    最近更新 更多