my code run fine
st.markdown(“”“ section[data-testid=“stSidebar”]
[aria-expanded=“true”]
{display: none;}
“””,
unsafe_allow_html=True)
I implemented this code at the beginning of my main.py file, which successfully disabled the sidebar. However, when I attempted to display the sidebar using [display: on;], it did not function as expected. I would appreciate your guidance on the correct method to re-enable the sidebar through a button press, using either display: on or display: yes. Additionally, I seek assistance in managing page visibility based on user permissions. Specifically, I need to restrict access so that not all pages are visible to every user, allowing only those pages for which access has been granted based on user credentials. Please provide the appropriate code to achieve this functionality for hiding and showing pages according to user rights.
Alternatively, if you don’t write anything to the sidebar and you hide sidebar navigation, you won’t need to use CSS at all. You can change the visibility of sidebar navigation while an app is running with st.set_option("client.showSidebarNavigation", False).
I appreciate your response, boss. However, I have a main.py file and 15 pages located in the pages folder. I would like to display only 3 pages for testing purposes for the user, while providing access to all pages for the admin user. Could you please guide me with the appropriate command and process to resolve this issue, including the complete code?
The tutorial has a complete working example. I recommend using st.navigation and st.Page as in the example and not a pages directory if you need to dynamically change which pages are available. In the example, you can see no left navigation before a user logs in. After you select a logged-in role, the correct pages for that role show in navigation.
If you are having trouble implementing the page navigation shown in the turorial, feel free to create a thread with more information about your project and how you tried to implement the linked solution.
I appreciate your swift response, Boss. Could you please provide any sample code that addresses my issue? Your assistance would be immensely helpful, as I am new to Streamlit. Thank you.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
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.
Performance cookies
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.
Functional cookies
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.
Targeting cookies
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.