Styling Grid Rows/Columns - the Vaadin 10 way?

Hi all,

let’s say I want to add a Column to my Grid which displays a double and applies a style if the number is negative.

In Vaadin 8 I would implement a StyleGenerator and return a fitting style-name in the String apply(…) method, then link it with setStyleGenerator(…) to the Column.

What are we supposed to do in Vaadin 10?
Use a ComponentRenderer like so?

gr.addColumn(new ComponentRenderer<Span, Person>(person -> {
  Span sp = new Span();
  sp.setText(String.valueOf(person.getSalary()));
  if (person.getSalary() < 0) {
    sp.addClassName("value-negative");
  } else {
    sp.removeClassName("value-negative");
  }
  return sp;
})).setHeader("Component-Column");

And what about Row-Styles? Would I have to use a ComponentRenderer like above for every single column?

No replies to this thread?
I was about to ask the same question…

Hi! This is currently a missing feature in Grid, but something we want to bring back.

Template/component renderers for each column are currently the only option for styling rows/cells.

Here’s the issue to follow: https://github.com/vaadin/vaadin-grid/issues/1297