Description
Component
UI (ui.*)
Severity
P2 - Medium (workaround exists)
Shiny Version
1.3.0
Python Version
3.13.2
Minimal Reproducible Example
from shiny import App, ui
# https://shiny.posit.co/py/api/core/ui.navbar_options.html#navbar-style-with-bootstrap-5-and-bootswatch-themes
app_ui = ui.page_navbar(
title = "Title",
theme = ui.Theme(
# version = 5, # throws syntax error
preset = "journal"
),
navbar_options = ui.navbar_options(
# class = "bg-primary", # throws syntax error
"bg-primary", # gives red navbar with black text
theme = "dark"
)
)
def server(input, output, session):
pass
app = App(app_ui, server)
Behavior
Per the example in the docs (only I'm using the journal theme instead of flatly), I believe I should be able to pass class
to ui.navbar_options()
, but that throws an error about invalid syntax at class
. Likewise for version = 5
in ui.Theme()
. By removing version = 5
and class
(but leaving "bg-primary"
) I get a result that runs, but is not consistent with what I believe is the R equivalent.
R Example
# R: 4.4.2
library(shiny) # 1.10.0
library(bslib) # 0.9.0
ui <- page_navbar(
title = "Title",
theme = bs_theme(preset = "journal"),
navbar_options = navbar_options(
class = "bg-primary",
theme = "dark"
)
)
server <- function(input, output, session) {
return(NULL)
}
shinyApp(ui, server)
This gives a navbar with white text on light red just like the journal Bootswatch page; that is the behavior I expect. The Python version (as best I can figure out) gives a light red navbar, but with dark text.
To my understanding this does not match the docs where it says:
The navbar's white text is controlled by the data-bs-theme="dark" attribute, which is used by Bootstrap for light text on a dark background.
Switching theme = "dark"
to theme = "light"
doesn't seem to have any effect here either.
Error Messages (if any)
Environment
Windows 10
R 4.4.2