How to add scroll bar in st.expander

I put many columns in st.expander, if I change the screen size or add more columns, each column width will be smaller, and the button size will be changed.

is there any method to add a horizonal scroll bar in st.expander?

There are extra considerations if you have multiple expanders and want them styled differently, but in the simplest case:

import streamlit as st

with st.expander('Cat'):
    st.write('Meow' + ' meow'*1000)

    [data-testid="stExpander"] div:has(>.streamlit-expanderContent) {
        overflow: scroll;
        height: 400px;

st.markdown(css, unsafe_allow_html=True)


Thanks and it works.
but it will still compress the column space and exceed the border of the expander。
I found a way to fix it.

        hide = """
            ul.streamlit-expander {
                overflow: scroll;
                width: 1500px;

        st.markdown(hide, unsafe_allow_html=True)
1 Like

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