Bootstrap navbar variables not working in bslib 0.6.1 but working in 0.5

Hi, this must be something simple, but I'm finding that the bootstrap 5 navbar variables are not working for me using bslib version 0.6.1.

Note that the bootstrap variable body-bg works in both versions.

Zev

# This shows a red nav bar in bslib 0.5 but not in 0.6.1
library(shiny)
library(bslib)

ui <- page_navbar(
  theme = bs_theme(version = 5, "navbar-bg" = "red"),
  title = "My App",
  nav_panel(title = "One", p("First page content.")),
)

server <- function(...) { }

shinyApp(ui, server)

With bslib 0.6.1, you need to set the argument preset = "bootstrap". You can have a look at ?bslib::bs_theme for more info.

library(shiny)
library(bslib)

ui <- page_navbar(
  theme = bs_theme(version = 5, preset = "bootstrap", "navbar-bg" = "red"),
  title = "My App",
  nav_panel(title = "One", p("First page content.")),
)

server <- function(...) { }

shinyApp(ui, server)

Wow, great! Thank you!

So preset = "bootstrap" is how you can use stock Bootstrap 5 styles. We introduced a new shiny preset, I think in 0.5.0, which became the default preset (i.e. preset = "shiny") in 0.6.0. If you could open an issue in the bslib github repo, I'd be happy to take a look soon. We do intend to allow the shiny preset to be customizable in the same ways as the base Bootstrap theme.

Hi Garrick! The solution @ Mwavu suggests works for me. I'm happy to open a GitHub issue but it seems like perhaps I was just missing an argument? You want me to open the issue?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

@zross you shouldn't need the preset = "bootstrap" in order for "navbar-bg" = "red" to work (we'd consider that a bug that we should fix).

That said, page_navbar() actually has a bg argument that does what you want. It'll also auto contrast the foreground color, but if it doesn't pick the right color, you can control it with inverse

library(shiny)
library(bslib)

ui <- page_navbar(
    title = "My App",
    bg = "red",
    inverse = TRUE,
    nav_panel(title = "One", p("First page content.")),
)

server <- function(...) { }

shinyApp(ui, server)