Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny datatable how to change theme

Tags:

r

themes

dt

shiny

I would like to apply a dark theme to a shiny application:

    library(shinythemes)

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

But the DT datatable does not follow the theme color.

How can I make it dark ?

Thanks a lot.

like image 522
Kelvin Cambridge Avatar asked Aug 31 '25 22:08

Kelvin Cambridge


1 Answers

In addition to your posted code, you must also add the following argument to your datatable function. Fully reproducible code below.

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)

like image 57
RDavey Avatar answered Sep 03 '25 12:09

RDavey