Some `bs_theme` arguments are seemingly ignored by `page_sidebar`
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
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() |
|---|---|
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.
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; }"
)
)