'Dash app: Conditional formatting of a dbc accordion with inline CSS

How can I style the dbc (dash bootstrap components) accordion buttons with a conditional color based on another value in my Dash app

image of accordion element

I am having trouble with styling the 'button bars' in a way that can be changed by the python script

Changing background color through the style attribute edits the 'body' color only

dbc.Accordion([
              dbc.AccordionItem(id='value',style={'background-color':'coral'})
              ])

I can change this color with additional style sheet in assets but this will not update with my app parameters.

.accordion-button:not(.collapsed) {
    background-color: red;
}

Can this be done with Dash inline CSS?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source