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'}
8 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.

4 Likes

This tip was of big help. Thanks.

Can you add the output to your component in this format?

four_card = dbc.Card(
    dbc.CardBody(
        [
            html.H5(dcc.Link("Name", href='/name'), className="card-title", style=style.TEXT_STYLE),
        ]
    ),  style='your-button-id'
)