Could a color picked from colorPicker Swatches tab have a name that can be used in styleName?

Hi there,

We have an entity “Category” with a “color” attribute (String) that user selected from ColorPicker Swatches tab. In the Category.Browse table screen, we want the “color” cell background being displayed in this color user picked. However, the selected color does NOT have a “standard color name” that can be used in “stylename” of the table cell.

What 's the correct way to style a table cell background with a user picked color?

Thanks,
-Mike

Hi Mike,

you can simply name your CSS styles using the following notation:


.v-table-cell-content.my-palette-6dffa8 {
    background-color: #6dffa8;
}
// add all variants for colours from swatches tab

And then use this generated name in your StyleProvider:


String stylename = "my-palette-" + category.getColor().replace("#", "");