Layout setting changes from default to wide after reloading page

Summary

Every time I reload my app my layout settings change from wide to default.

Steps to reproduce

Code snippet:
main.py

import streamlit as st
from st_pages import Page, Section, show_pages, add_page_title, hide_pages
from utils.local_connection_utils import create_con_directory


def __init__():
    st.session_state.page_config = st.set_page_config(page_title="etc", page_icon=None,initial_sidebar_state="expanded", layout="wide"
)
    with open("css/style.css") as f:
        st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
    
    
__init__()



show_pages(
    [
        Page("main.py", "Home"),
        Page("page1.py","Page 1"),
        Page("page2.py", "Page 2"),
        Page("page3.py","Page 3"),
    ]
)

Expected behavior:

On reloading on while on page 1 the layout should stay as wide but it changes to default.

Actual behavior:

The layout changes to default. Once I navigate to the main page the layout is then again loaded as wide.

1 Like

Hey @RusabKhan,

Thanks for sharing this question! I’m trying to run the code snippet you shared to reproduce this issue, but unfortunately it’s not runnable because I don’t have the style.css file, or any of the other page files that are referenced in the snippet.

This is what happens when I run a more minimal version of your app:

LayoutExample

As you can see, the layout setting is persisting when I reload the page.

Happy to try to reproduce this again if you want to share a revised code snippet.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.