Open ncullen93 opened 1 year ago
Apparently datatables has moved to using box-shadow for selected rows. This works:
my_theme <- bslib::bs_add_rules(
my_theme,
rules = sass::as_sass('table.display.dataTable > tbody > tr.selected > *{
box-shadow: inset 0 0 0 9999px lightgray !important;
color: black;
}')
)
What may be happening here is that the latest version of DT will now correctly recognize that bslib is using Bootstrap 5 and will automatically apply the BS5 styles to datatables (where previously it was using BS4 styles). I vaguely remember seeing that the newer BS5 styles used box-shadow
.
Here are the rules I've used to change the default datatables styles for bs_theme(preset = "shiny")
, you might find some interesting things here:
Thanks! I would expect something like this to work, but it has no effect:
my_theme <- bslib::bs_theme(
version = 5,
preset = 'shiny'
)
my_theme <- bslib::bs_add_variables(
my_theme,
"table-striped-bg" = "red",
"table-active-bg" = "red"
)
Changing table-hover-bg
does work, however. And note that the table-hover-bg
doesnt work when the preset is "bootstrap".
Yeah, only the bs_theme(preset = "shiny")
uses the var(--bs-table-*-bg)
CSS variables which take their values from their Sass counterparts.
The rules here in bslib are essentially a patch for behavior that should be implemented upstream in DT. I opened an issue there that covers some of this behavior, I'll add a note there: https://github.com/rstudio/DT/issues/1081
Updating
table-active-bg
has no effect for preset of "shiny" or "bootstrap", whiletable-color
does work, for instance. See reprex:Noticing also that there may be mixed use of
selected
andactive
classes when selecting datatable rows. Not sure which is the right one. I'm using the following code fromtables/_rules.scss
as reference to make me think I should updatetable-active-bg
: