You could use “generated columns”, generate Label components in the generator and assign any CSS you want with io.jmix.ui.component.HtmlAttributes
bean.
@Inject HtmlAttributes htmlAttributes;
htmlAttributes.applyCss(label, "color: white");
Note that structure of the Vaadin component can be complex - it can consist of several html “div” elements, and all of them inherit some styles from the theme, so assigning just one CSS for the parent component could appear to be not enough.
Personally I have implemented similar requirement in my CUBA project in the past.
I preferred to use limited number of colors and CSS styles.
- Used color picker component only with the “swatches” tab enabled, so users could only choose one of preconfigured colors.
- Created a CSS style in the theme for each of the colors. For example for Table:
.v-table-cell-content.ffffaa .v-table-cell-wrapper {
color: #ffffaa;
}
And assigned CSS styles dynamically with styleProvider
handler method.