Black Lives Matter. Please consider donating to Black Girls Code today.

Link to an external site in a new browser tab

Hello,

I’m trying to create a link in a dash app to an external site to open in a new tab.

I tried to add target="_blank" to the dcc.Link("Link to external site", href=url, target="_blank") but dash doesn’t like it.

Also tried to use html.A("Link to external site", href=url, target="_blank") but this didn’t work either.

Appreciate any help (perhaps there is a trivial one I’m missing).

Thanks

@bkelemen - This works for me. Here’s what I did:

import dash_html_components as html

app = dash.Dash()

app.layout = html.Div([
    html.A("Link to external site", href='https://plot.ly', target="_blank")
])

if __name__ == '__main__':
    app.run_server(debug=True)

Could you post a small, reproducable example?

3 Likes

Chris, thanks a lot!

Now I’m not sure what I did yesterday to not get it working :frowning: as the code works perfectly. Sorry for that.