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,