Use an IF – Elseif – Else condition in Twig when there are more than two cases. Twig checks the conditions in order and shows the HTML of the first condition that is true. You can add this code from Twig Code Examples > IF – Else – Elseif in the widget creator. To learn how, see Showing twig code examples.
{% if product_stock == 0 %}
{% elseif product_stock > 0 and product_stock < 20 %}
{% elseif product_stock >= 20 %}
{% endif %}
In this example, product_stock is the name of an attribute. The first part is shown when the value is 0, the second part when it is between 0 and 20, and the third part when it is 20 or more. You can add as many {% elseif %} parts as you need.
To show HTML when none of the conditions is true, add {% else %} before {% endif %}. For example, with a Dropdown attribute:
{% if icon_position == "left" %}
...
{% elseif icon_position == "right" %}
...
{% else %}
...
{% endif %}