Creation of a new Page

Hello All,

is there way we can create a new Page with a button click using Streamlit?

As of now I could keep on increasing my page’s length by keeping on adding widgets, but I want them to a new page.

Thanks in Advance.

Hey @Harish_Kodarapu,

You can do this with the st.radio command in streamlit. Ideally you would use this because it preserves the state of the radio button no matter what you do on each page (click buttons, display data etc…)

import streamlit as st
my_page = st.sidebar.radio('Page Navigation', ['page 1', 'page 2'])

if my_page == 'page 1':
    st.title('here is a page')
    button = st.button('a button')
    if button:
        st.write('clicked')
else:
    st.title('this is a different page')
    slide = st.slider('this is a slider')
    slide

gives:
for the first page:

for the second page:

Happy Streamlit-ing!
Marisa

1 Like