How to style expander add background color based on cell value


Having streamlit app that display expanders that includes data from a dataframe.
Need to change the background color of the expanders based on the value existing in column occupation

Expected behavior:
All the expanders that have as occupation
teacher get the background color green
Engineer get the background color red
And so on…
Actual behavior:

All the displayed expanders are matching while what i want is to differ between them based on the occupation.

Debug info

  • Streamlit version: 1.18
  • Python version: 3.10
1 Like

Can you post a sample minimal code that we can explore?

Is this question another version of that: How to styled st.expander in streamlit and python based on value ?

1 Like