Toggle a class for an alert based on 3 conditions

I’ve been searching throughout the forum and documentation, including reports such as this one, and I am not clear if what I want is feasible:
I have an alert, and I want to change its type (danger, warning, success), based on a condition picked up on page loading from an expression. I have tried toggling class and assigning dynamic attributes, but I must be doing something wrong.
Base code is:

<div class="alert alert-danger" role="alert" id="alert_impact"></div>

Yes you need to add a dynamic attribute for the class and pick your condition per each of the classes you want to add.

Thanks @Teodor, I understand the concept, but I struggle with the implementation, in the sense that I’m not sure where to start by adding a dynamic attribute in the first place. If I then use the condition to change the class, it doesn’t have an effect:

<div class="alert alert-danger" role="alert" id="alert_impact" dmx-style:alert-warning.important="( == 2)" dmx-style:alert-warning.important="( == 2)">

You are using the wrong dymanic attribute. You need to use class toggle not style.


Thanks @brad and @Teodor. It works indeed.
For any further person ever researching this topic, this is the screenshot of the working setup and the resulting code:

<div class="alert alert-danger" role="alert" id="alert_impact" dmx-class:alert-danger="( == 1)"

dmx-class:alert-warning="( == 2)"

dmx-class:alert-success="( == 3)">