✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

To give more than two colors in the dash datatable headers


Anyone knows how to give more than two colors to the headers??

I tried with below logic but got incorrect syntax
‘backgroundColor’: ‘rgb(230, 230, 230)’,
‘fontWeight’: ‘bold’
‘if’: {‘column_id’: c},
‘backgroundColor’: ‘rgb(255, 191, 0)’,
‘color’: ‘#000000
} for c in [‘Working Days’,‘Total Work Hrs’,‘PTO’,‘Total Work Hrs Available’,‘Revenue’],

                          'if': {'column_id': d},
                          'backgroundColor': '#51f542',
                          'color': '#000000'
                      } for d in ['Actual Hrs spend','Actual cases coded','ROI'],

Hi @Allan, and welcome to the Dash community :slight_smile:

try this syntax:

                "if": {"column_id": c},
                "backgroundColor": "rgb(255, 191, 0)",
                "color": "#000000",
            for c in [
                "Working Days",
                "Total Work Hrs",
                "Total Work Hrs Available",
        + [
            {"if": {"column_id": d}, "backgroundColor": "#51f542", "color": "#000000"}
            for d in (["Actual Hrs spend", "Actual cases coded", "ROI"],)

Thanks alot @AnnMarieW :slight_smile:
It worked

1 Like