简体   繁体   中英

How do you change the color of title of table generated with DT library in shiny app?

I am rendering a table in my shiny app. Table is generated with DT library. This is the code:

output$table <- DT::renderDataTable(DT::datatable({# Displaying table in section tab for principal and director
    if (user_logged$Designation=='director'|user_logged$Designation=='principal'){
    data <- teacher_info[teacher_info$Section == input$sections,]
    data <- data%>%
      select(-c(Section))
    }

This is the output: Table As you can see due to background color, column title and other title becomes obscure. I want to change the color of those texts and if possible I also want to change background color of table.

I think yours is a similar question to the one here How to change shiny app dataTableOutput font color and auxiliary table element color?

you can add

tags$style(HTML(
".dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing, .dataTables_wrapper .dataTables_paginate {
                    color: #ffffff;
                    }"))

as inline CSS to your ui, the link also shows how to change the page numbers if relevant

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM