I’m wondering if it is possible to use dcc.Dropdown to navigate between pages in the Dash multi-page app?
I’ve found an example using dbc.Button here but when I tried to modify it to use dcc.Dropdown it doesn’t work correctly (the page is refreshed when the dropdown is opened, not when the value is selected, e.g. after selecting an option from the dropdown I need to open the dropdown again for dcc.Link to actually load it).
I tried this in the layout:
dcc.Link( dcc.Dropdown( id='navigation-dropdown', options=['Link1', 'Link2'], value='Link1' ), id="navigtion-link", href="/", ),
@callback( Output("navigation-link", "href"), Input("navigation-dropdown", "value"), prevent_initial_call=True, ) def update_href(dropdown): if dropdown== 'Link1': return "/link1" else: return "/link2"