Button with Link?

Is it possible to use Button with Link?

For example:

dcc.Link("back", href=f"url")

works fine, but

html.Button(dcc.Link("back", href=f"url"), className='three columns'),

Will make the button appear to be like a link, but does not do anything when clicked.

Maybe try dcc.Link(html.Button('back'), href=...)? Alternatively, you can use CSS to style the <a/> tag that is embedded within dcc.Link as a button

1 Like

Could you show a working example?

Hi @mail8

Here are some options:

If you are using dash-bootstrap-components library, the dbc.Button has an href prop:

dbc.Button("Go Home!", href="/")

Otherswise you can wrap an html.Button (or an icon or image…) in an html.A Anchor component, for example:

html.A(html.Button("Go Home!"), href="/")

If you are using dash-mantine-components:

dmc.Anchor(dmc.Button("Go Home!"), href="/")

I hope this helps.

1 Like