bslib icon indicating copy to clipboard operation
bslib copied to clipboard

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

Open lukebandy opened this issue 1 year ago • 2 comments

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

lukebandy avatar Oct 17 '24 09:10 lukebandy

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:

  • #978
  • #940
  • Also related: #253

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.

gadenbuie avatar Oct 17 '24 12:10 gadenbuie

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; }"
        )
      )

see24 avatar Oct 31 '24 14:10 see24