How to navigate to a certain segment based on user input?

@arraydude I think that might not be what they’re after, I think they already have a large list that can be added but want to jump to parts on the page. Sorry if I’ve misunderstood.

@junkrat If you want a link to a position on an HTML page you can create hidden divs with IDs, then use a standard link to jump to them:

import streamlit as st


link_number = st.number_input("What subheading do you want to go to?", value=50)
st.markdown(f"<a href='#linkto_{link_number}'>Link to {link_number}</a>", unsafe_allow_html=True)

for i in range(100):
    st.markdown(f"<div id='linkto_{i}'></div>", unsafe_allow_html=True)
    st.subheader(f"Subtitle {i}")
    st.write(f"I am a thing {i}")

This should give you a link that jumps to the relevant element on the page.

3 Likes