Found the solution on the Vaadin forums, in case someone find the same problem :
This is explained in the documentation here: Grid | Components | Vaadin 23 Docs
Note the comment in the CSS file, which shows you where you have to put your CSS file to make it work.
Basically, using the grid.setClassNameGenerator