I have a classic multi page app made in Plotly Dash, but I can't figure out how to highlight a page in the navigation that is currently visited. I managed to get the active pathname with a callback, but I still don't know how I can use this to add a className "active" to one of the links in the navigation.
@app.callback(Output("print", "children"), [Input("url", "pathname")])
def callback_func(pathname):
print(pathname)
return pathname
This is how I render my navigation:
html.Div(
className="items",
children=[
html.Div(
dcc.Link(
f"{page['name']}",
href=page["relative_path"],
)
)
for page in dash.page_registry.values()
],
),