Change the color of column headers in DT table

Hi all,

Is there a way to change the column header font to White?. below is the sample code to render the DTtable in shiny

 output$tab <- DT::renderDT(DT::datatable(tab1, rownames = FALSE, escape = FALSE, extensions = list("Scroller"), 
                                            class = "compact nowrap stripe hover",
                                            options = list(dom = 't', ordering = F))%>% 
                                            formatStyle(columns=colnames(tab1),
                                            backgroundColor = '#222222', color = "white")%>%
                                            formatStyle(columns = colnames(tab1), fontSize = '85%'))

You could add some jquery to change the font after loading under the table options:


table <- DT::datatable(
         data,
         options = list(
                        initComplete = JS(
                            "function(settings, json) {",
                            "$(this.api().table().header()).css({'color': '#fff'});",
                            "}")))
})

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.