简体   繁体   English

更改 DT Shiny R 中过滤器标签的颜色

[英]Change color of filter labels in DT Shiny R

I have a DT in shiny where I have added a filter to each of the column names.我在 shiny 中有一个 DT,我在每个列名中添加了一个过滤器。 I have also added a custom css to change the color of the table.我还添加了一个自定义 css 来更改表格的颜色。 However, when I go to filter a column, the values on the slider blend in with the background.但是,当我用 go 过滤列时,slider 上的值与背景融为一体。 I would like to make the values "black".我想将值设为“黑色”。 See attached photo.见附图。

#ui body
body(
 tags$style(HTML('table.dataTable tr:nth-child(even) {background-color: #1b1b21 !important;color: #e8e8e8 !important;}}')),
        tags$style(HTML('table.dataTable tr:nth-child(odd) {background-color: #242932 !important; color: #e8e8e8 !important;}')),
        tags$style(HTML('table.dataTable th {background-color: #1b1b21 !important;}')),
        tags$style(HTML(".dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate .paginate_button, .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
            color: #5daa45 !important;
        }"))

DTOutput("mytable")
)

在此处输入图像描述

It could be done similar to how you are changing the other colors, here are the CSS selectors:它可以类似于您更改其他 colors 的方式来完成,这里是 CSS 选择器:

tags$style(HTML('table.dataTable thead tr td {color: black !important;}')),

Reproducible example:可重现的例子:

library(shiny)
library(DT)

ui <- fluidPage(
  tags$style(HTML('table.dataTable tr:nth-child(even) {background-color: #1b1b21 !important;color: #e8e8e8 !important;}}')),
  tags$style(HTML('table.dataTable tr:nth-child(odd) {background-color: #242932 !important; color: #e8e8e8 !important;}')),
  tags$style(HTML('table.dataTable thead tr td {color: black !important;}')),
  tags$style(HTML('table.dataTable th {background-color: #1b1b21 !important;}')),
  tags$style(HTML(".dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate .paginate_button, .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
            color: #5daa45 !important;
        }")),
    dataTableOutput("mytable")
)

server <- function(input, output, session) {
  
  output$mytable <- renderDataTable({
    datatable(cars,filter = "top")
  })
}

shinyApp(ui, server)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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