The following example app create a page_navbar with a dark/light mode switch.
I'd like to ask how to load different logo image in front of the title depending on the display mode selected, e.g. for dark model use a logo with black backgroupd, and for light mode load the logo with a white background.
app.py
from shiny import App, ui
from pathlib import Path
app_ui = ui.page_navbar(
ui.nav_panel("A", "Page A content"),
ui.nav_panel("B", "Page B content"),
ui.nav_panel("C", "Page C content"),
ui.nav_control(ui.input_dark_mode(id='mode')),
title = ui.div(
ui.tags.img(
src='asset/sample_logo.png',
height='40px',
style='margin-right: 10px;',
),
'App with Navbar & Logo',
),
id="page",
)
def server(input, output, session):
pass
app_dir = Path(__file__).parent
app = App(app_ui, server, static_assets=app_dir / 'www')
Currently the logo image file "logo.png" is stored at the "www/asset/" folder in the root directory of the app. (Reference: Serve local files)