0

I am using Vaadin v23 and I am trying to change bg-color of a row when certain condition is met, like below:

grid.setClassNameGenerator(row -> row.getRemoved() ? LumoUtility.Background.CONTRAST : "");

Why doesn't it work?

I tried to do it with custom .css file and it works, but I would prefer to use built-in CONTRAST style.

grid.setClassNameGenerator(row -> row.getRemoved() ? "grid-row-removed" : "";
Burak
  • 83
  • 1
  • 7

1 Answers1

4

The problem is that the CSS must be in the scope of the grid.

So you must define the class in /frontend/themes/<your theme>/components/vaadin-grid.css

Then you could do it like this:

.grid-row-removed {
    background-color: var(--lumo-contrast);
}
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82