Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide sidebar in Streamlit?

I have a Logout button in the sidebar. I want to hide/disappear the complete sidebar when I click the Logout button. This my code

import streamlit as st
name, authentication_status, username = authenticator.login("Login","main")
if authenticator.logout("Logout", "sidebar"):
    st.markdown("""
      <style>
          [data-testid="collapsedControl"] {
                display: none
            }
       </style>
       """, unsafe_allow_html=True)

I tried this Completely disable sidebar?. But it doesn't work.

like image 228
Abdul Awal Nadim Avatar asked Sep 07 '25 08:09

Abdul Awal Nadim


1 Answers

I expect this markdown to solve your problem.

st.markdown("""
    <style>
        section[data-testid="stSidebar"][aria-expanded="true"]{
            display: none;
        }
    </style>
    """, unsafe_allow_html=True)
like image 54
Jamiu S. Avatar answered Sep 11 '25 02:09

Jamiu S.