Go back to top of a large page/ sidebar radio button

Hi @kantuni, I have the exact same problem and Iโ€™m wondering if maybe there is an alternative since weโ€™re now a year later?

Thanks!

EDIT: nevermind that, Iโ€™ve found a workaround by adding a hidden div.

pages = ["Page 1", "Page 2"]
section = st.sidebar.radio('', pages)     # this is my sidebar radio button widget

# hidden div with anchor
st.markdown("<div id='linkto_top'></div>", unsafe_allow_html=True)    

if section == "Page 1":                  # This is the beginning of my first page
    st.header("This is my first page")
    st.write("Let's pretend there is a lot displayed on this page")

    # add the link at the bottom of each page
    st.markdown("<a href='#linkto_top'>Link to top</a>", unsafe_allow_html=True)

if section == "Page 2":
    st.header("This is my second page")
    st.write("Let's pretend there is a lot displayed on this page")

    # add the link at the bottom of each page
    st.markdown("<a href='#linkto_top'>Link to top</a>", unsafe_allow_html=True)
2 Likes