CSS Styling and Expressions

This question arose during the Monthly Modeling Highlight on Expressions.

Is it possible to add CSS Styling to an Expression? I don’t think it’s modelable but can a developer do it for you?

Hi @malcolm-silver-ice,

Yes. We can model an expression which renders HTML structure like image example below. With that, we can inject class names or id or anything that CSS selectors can hook into. Then the developers can provide and import to source code the corresponding CSS files.

Expression:

"<img class='animal-image' src='https://www.shareicon.net/data/64x64/2016/09/30/837630_animal_512x512.png'/>"

Styles:

.animal-image {
    width: 200px;
}

In complicated use cases, we still recommend to customize via code to achieve the desired styles.