[英]Change color of filter labels in DT Shiny R
我在 shiny 中有一個 DT,我在每個列名中添加了一個過濾器。 我還添加了一個自定義 css 來更改表格的顏色。 但是,當我用 go 過濾列時,slider 上的值與背景融為一體。 我想將值設為“黑色”。 見附圖。
#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")
)
它可以類似於您更改其他 colors 的方式來完成,這里是 CSS 選擇器:
tags$style(HTML('table.dataTable thead tr td {color: black !important;}')),
可重現的例子:
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.