Black Lives Matter. Please consider donating to Black Girls Code today.

Changing the style of a div with a callback on dash

Hi, I’m trying to change the style of a div in a callback, a html component like a button it´s going to trigger the change. Anyone knows how can i do that??

what are the input and output parameters that i should pass?

You could update the style property of the component:

@app.callback(Output('your-button-id', 'style'), [Input(...), ...])
def update_style(...):
    # ...
    return {'color': 'blue'}
6 Likes

Hi, can I update the classname property of the component?

1 Like

I have the same question. Is it possible to update the class name using a callback?

Yes, just use ‘className’ instead of ‘style’ in the Output of the callback.

1 Like

This tip was of big help. Thanks.