Is it possible to change the background color of a column?

Hello,

I created 2 columns

col1, col2 = st.columns([6, 2])

I need column 2 to be a certain shade of grey, however I’m a bit stuck if that’s realistically possible to do. Any help would be appreciated!

1 Like

You could do a quick CSS injection, or try using a 🎨 Styleable Container - streamlit-extras

Code
import streamlit as st

col1, col2 = st.columns([6, 2])

with col1:
    "# Column 1"
    "Text "*100

with col2:
    "# Column 2"
    "Text "*20

st.markdown("""
    <style>
        [data-testid="column"]:nth-child(2){
            background-color: lightgrey;
        }
    </style>
    """, unsafe_allow_html=True
)
2 Likes

Thank you! This worked

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