Hi Stefan,
You can also use the (official Mendix) customString widget, which lets you run a microflow that returns a string, which you can display with HTML elements. In this you can 'construct' a element with a variable color.
simple example:
'<div style="background-color: ' + $Object/colorAttribute + ';">I like cake</div>
I did something like this before and had to resort to the usage of the HTML snippet. Here is an instruction of how it could be implemented.
var attr = document.getElementsByClassName("attrClass")[0];
var color = attr.textContent;
var containerTarget = document.getElementsByClassName("targetContainerClass")[0];
containerTarget.style.backgroundColor = color;
You could create containers which have a color specific class added to them, and show the 'correct' containers through conditional visibility in Mendix as per your attribute.
Would that solve your issue?