How to implement a button with the function "back to top of the page" by callback?

Hi guys,

I just want to implement a button with the function “back to top of the page”, how can I realise it with the callback? Is anyone that already has tried before?

Thanks

Hi @jianqiao

I solved this issue without any Callback.

I added an image in the left top of my app:

html.Img(src=app.get_asset_url("Bull-vs-bear.gif"), id="home"),

As you can see, I named the id “home”.

Then in the bottom of the page I added the following dcc.Link:

dcc.Link("back to top of the page", href='#home', style={íf you want some specific style to show the button}),

As the property href is setted with the neme of my image id, the pege will be going to the top any time the link button is clicked.

You can see it working in my app: https://companyanalysis.herokuapp.com/

1 Like