Callback to change only one element of style dict

Hi @domingo

You can include the style as a State in the callback, then update it like any dict - for example:


@app.callback(
    Output("my_div", "style"),
    Input("button", "n_clicks"),
    State("my_div", "style")
)
def update(n, style):
    style["backgroundColor"] = "red"
    return style
1 Like