Switching page with buttons

Hello Everyone
I am creating a Streamlit app where I want to add a button which should take a user to another page. I tried some examples but all of them have sidebar coming up. I don’t want a sidebar in my app. Please help me implementing this solution. Also the solution should work on Streamlit Cloud. Thank you.

Hi @AhXaN,

Thanks for sharing this question!

Make sure to use the initial_sidebar_state="collapsed" keyword in st.set_page_config(). See docs st.set_page_config - Streamlit Docs.

Here’s an example of code for switching pages using st.switch_page`:

# List of pages
pages = {
    "🎡 Scroll container": "./pages/2_🎡_Scroll_container.py",
    "❓ st.query⚊params": "./pages/3_❓_st.query⚊params.py",
    "📄 st.switch⚊pages": "./pages/4_📄_st.switch⚊pages.py",
    "🔗 Link column formatting": "./pages/5_🔗_Link_column_formatting.py"

# Dropdown to select the page
selected_page = st.selectbox("Select a page:", list(pages.keys()))

# Button to switch page
switch_page = st.button("Switch page")
if switch_page:
    # Switch to the selected page
    page_file = pages[selected_page]