Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to update URL through dropdown?

Hi All,

I have a multi-page dashboard and want each page to have a dropdown where the values are the links to Home, App1, App2, etc.

Something like:
options = [‘label’: Home, html.A(id=‘home’, ‘value’: href=’/’)].

Could someone please guide me on how to activate URL changes with a dropdown box?

Thanks,
Jeffrey.

You can do it by modifying the dcc.Location pathname in a callback:

@app.callback(dash.dependencies.Output('url', 'pathname'),
              [dash.dependencies.Input('dropdown', 'value')])
def change_url(dropdown_value):
    return dropdown_value
2 Likes

Thanks rafaelc. I didn’t find that to work for me for some reason when I first attempted this issue. I ended up importing webbrowser and using:

webbrowser.open(url + ‘/apps/app1’, new=0, autoraise=True)

Sadly this opened new tabs/windows rather than the tab I was using for the dashboard.