rstudio / bslib

Tools for theming Shiny and R Markdown via Bootstrap 3, 4, or 5.
https://rstudio.github.io/bslib/
Other
490 stars 58 forks source link

Shiny preset masks `$bslib-sidebar-bg` with a custom property in dashboard mode #1126

Closed gadenbuie closed 1 week ago

gadenbuie commented 1 month ago

The Shiny preset sets --bslib-sidebar-bg

https://github.com/rstudio/bslib/blob/85b042832e1520b5f06dc95c769396816be76eca/inst/builtin/bs5/shiny/_rules.scss#L138

but this masks $bslib-sidebar-bg if set

https://github.com/rstudio/bslib/blob/85b042832e1520b5f06dc95c769396816be76eca/inst/components/scss/sidebar.scss#L2

because .bslib-sidebar-layout will always consult the CSS variable before falling back to the default color

https://github.com/rstudio/bslib/blob/85b042832e1520b5f06dc95c769396816be76eca/inst/components/scss/sidebar.scss#L17

Generally speaking the Shiny preset _rules.scss comes before sidebar.scss (or even in a separate Sass compilation), but I think we can safely assume that if $bslib-sidebar-bg exists we should use that value instead of our default.