How to change style css based on cell value in dataframe

i have a streamlit app that i want to use CSS hacking to change the style of st.expander based on returned value from dataframe.

I am using st.markdown() but noting it change and i did check that the div class is correct.

code:


def card(ID,name,nickname,mother_name,status_type,v1,v2,v3,v11):
    
    ex = st.expander(name)
    st.markdown(
    '''
        <style>
                .streamlit-expander.st-e8.st-at.st-as.st-c8.st-cy.st-b7.st-e9.st-ea.st-eb.st-ec{
                    @if {status_type} == 'employee'{
                        font-size:50px !important;
                        background-color:#64615d;
                        color:#f7f7f7;
                    }
                    @else if {status_type} == 'supervisor'{
                        background-color:#42ae8b;
                        color:#2d2a2a;  
                    }
                    @else if {status_type} == 'ceo'{
                        background-color:#d92121;
                        color:#eae5e5;  
                    }
                    
                }
                
        </style>
    ''',
    unsafe_allow_html=True,
    )

    if status_type in ['employee', 'supervisor', 'ceo']:
        with ex:
            f"ID : {ID}",
            f"NickName: {nickname}",
            f"mother_name: {mother_name}",
            f"current_status: {status_type}",

    return ex
1 Like

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