Aggrid: Is there a way to color a row based on a column value?


I’m using streamlit-aggrid custom component to display dataframes. I’d like to color an entire row based on a specific column’s value. I’m not sure how to do it as there are no examples provided for this. Please help.

Best wishes,


I figured out how to do it, thanks to code to enable other functionality not directly supported that a user posted on the Aggrid thread in Show the Community channel. The following snippet should help (I’m assuming the dataframe has a column called state, and you know about using Aggrid otherwise including imports):

            jscode = JsCode("""
            function(params) {
                if ( === 'failed') {
                    return {
                        'color': 'white',
                        'backgroundColor': 'red'
            gridOptions =
            gridOptions['getRowStyle'] = jscode

            grid_response = AgGrid(

Hope this helps others searching for a similar answer,


1 Like

hi there,

what if I want to color a row, based on a condition between other fields/columns in my dataframe?
How do the JS function will look like? how do i send over the params?

suppose I have a dataframe with the following fields:
ColumnA, ColumnB, ColumnC
and I want to apply a certain format for the entire row, if the following condition is true: ColumnA != ColumnB+ColumnC.

please help! Thanks