Home > Blockchain >  How to change the height of streamlit sidebar
How to change the height of streamlit sidebar

Time:11-30

I tried couple of work arounds to change the height of streamlit sidebar using css. One of my approach is the code below but yet it does not solve my problem. I found some suggested approaches in enter image description here

CodePudding user response:

Try this code to see if it solves your problem. I think it should. You have to pay close attention to the classes by using dev tools.

Note: by adding !important to your css rule will overwrite the default css. I think with this you should be good to go.

import streamlit as st


st.markdown("""
    <style>
      section[data-testid="stSidebar"][aria-expanded="true"]{
        height: 80% !important;
      }
      section[data-testid="stSidebar"][aria-expanded="false"]{
        height: 80% !important;
      }
    </style>""", unsafe_allow_html=True)

st.sidebar.markdown("Adjust sidebar height")

output: enter image description here

  • Related