【发布时间】:2021-08-27 07:42:10
【问题描述】:
问题与R DT override default selection color 非常相似,使用了部分代码,但最重要的是我想使用https://github.com/rstudio/bslib 进行样式设置。
我想在 DT 表中选择一行时覆盖默认颜色并失败数小时。
这里有一些代码可以使用
library(shiny)
library(DT)
library(bslib)
color_sel <-"#7cfc00"
ui <- fluidPage(
theme = bslib::bs_theme(version = 4,
bootswatch = "flatly",
# bootswatch = NULL,
primary = '#00488E',
secondary = '#4AB9FA',
success = "#4AB9FA",
info = "#4AB9FA"
) %>%
bs_add_variables(
"body-bg" = "#EEEEEE",
"font-family-base" = "monospace",
"table_active_bg" = color_sel
)
,
# tags$style(HTML(paste0("table.dataTable tbody tr.selected td, table.dataTable td.selected{background-color: ", color_sel," !important;}"))),
fluidRow(dataTableOutput("tbl"))
)
server <- function(input, output){
output$tbl <- renderDataTable({
datatable(mtcars)
})
}
app <- shinyApp(ui = ui, server= server)
runApp(app)
如您所见,我尝试了两个地方也用漂亮的绿色覆盖了标准蓝色,但它不起作用。 bs_add_variables() 正在工作,由 body-bg 和 font-family-base 检查。怎么了?
【问题讨论】:
-
嗨,安迪,你找到解决办法了吗?