Is there any Streamlit method for navigating to a particular anchor within the webapp.
If a title has an anchor for example is there any way to get the page to navigate to that particular section?
Is there any Streamlit method for navigating to a particular anchor within the webapp.
If a title has an anchor for example is there any way to get the page to navigate to that particular section?
Hi @jamestaylor,
Anchors are automatically added to header text.
For example, if you define a header text using:
st.header("Section 1")
Then you can create a link to this header using:
st.markdown("[Section 1](#section-1)", unsafe_allow_html=True)
Iβve also created a demo app showing this in action (https://share.streamlit.io/dataprofessor/streamlit/main/anchor_app.py)
And the corresponding code on GitHub is available here (streamlit/anchor_app.py at main Β· dataprofessor/streamlit Β· GitHub)
Hope this helps
Hi @dataprofessor,
Thank you for the reply!
Is there a way to make the page navigate to that link programmatically without having the user click on the link?
Hi @jamestaylor,
A programmatic way of having users navigate to various sections on the app can indeed be performed using various widgets such as st.buttons
or st.selectbox
but these require users to click on these widgets to select which anchors to navigate to.
Iβve actually created a video (see link below) on adding a custom top navigation bar that you can modify and use anchor links instead of external URLs as Iβve done in the video.
Links:
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.