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

Some `bs_theme` arguments are seemingly ignored by `page_sidebar` #1123

Open lukebandy opened 1 month ago

lukebandy commented 1 month ago

Describe the problem

To be honest this is a null issue as it's fine to just use page_navbar(), but did lose me some time to work around.

Doesn't work:

library(bslib)
ui <- page_sidebar(
    title = "Cool app",
    theme = bs_theme(
        preset = "flatly",
        primary = "#95a5a6",
        success = "#3F2A56"
    ),
    sidebar = sidebar()
)
server <- function(input, output) {}
shinyApp(ui, server)

But page_navbar() works:

library(bslib)
ui <- page_navbar(
    title = "Cool app",
    theme = bs_theme(
        preset = "flatly",
        primary = "#95a5a6",
        success = "#3F2A56"
    ),
    sidebar = sidebar()
)
server <- function(input, output) {}
shinyApp(ui, server)

And other arguments (from the documentation) work with page_sidebar:

library(bslib)
ui <- page_sidebar(
    title = "Cool app",
    theme = bs_theme(
        bootswatch = "darkly",
        base_font = font_google("Inter"),
        navbar_bg = "#25443B"
    ),
    sidebar = sidebar()
)
server <- function(input, output) {}
shinyApp(ui, server)

Session Info

R version 4.4.1 bslib: 0.8.0

gadenbuie commented 1 month ago

Thanks for the report @lukebandy. I think I see what you mean be "works" and "doesn't work": in page_navbar(), changing the primary color changes the navbar background color; page_sidebar() on the other hand doesn't use primary and instead follows $navbar-bg.

page_sidebar() page_navbar()
image image

There's a group of issues around this behavior:

In this case, setting page_navbar(inverse = FALSE) in the second example gives the same results as with page_sidebar(), which doesn't have an inverse argument.

see24 commented 4 weeks ago

I found a work around to manually set the page_sidebar header background"

theme = bs_theme(bootswatch = "litera") %>%
      bs_add_rules(
        list(
          "body { --bslib-page-sidebar-title-bg: #3f5a36; }"
        )
      )