Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Display Colour in table cell as component
Hello,
I'm developing an app that allows the user to set specific color to a record.
What I need to achieve is that the color should be displayed as a label in a table row containing specific record.
For example - if I have three columns in my table (Name, Phone, Status) - I'd like to add a color-component in fourth column (Name, Phone, Status, Color) as some kind of square or whatever.
Is there a component that will allow me to do that?
Thank you in advance
Tom
Hi,
one easy solution I've seen used a lot is a Label with ContentMode set to HTML and a suitable snippet as the Value. So something like
<div class="color-box" style="background-color: #[yourcolor];"> </div>
(or maybe a <span> instead of a <div>)
Then use the class name to add it suitable width and height in your theme.
-Olli
Thank you for the reply. I've managed to workaround my case by using disabled button, with CSS style injected dynamically. It's not perfect, but does its job :)
Nice :)
You can even enable it for click events if you need them later.
-Olli
hmm, I'd never considered it that way ;)
All the magic is to generate a column, inject dynamically CSS code containing button color and overriding 'disabled' style, so the button is not greyed out ;)
And here it is: