first and foremost, I’m very new to Vaadin although I’m starting to get comfortable with it So please excuse my question if it is trivial. I searched a lot but could not find anything that solves my issue.
In my java program there is a class that contains a grid. I changed the style of the grid via a .css file and importing it @CssImport(value = "./styles/grid.css", themeFor = "vaadin-grid").
My .css file (stripped of the non-essential parts) looks like this:
Now my issue is the following: Setting text-align of both body and header-cells works fine. For header-cells text-transform: uppercase; works, too. However, for some reason I am not able to get font-weight: bold; to work neither for header-cells nor for body-cells. In fact, I tried to change the font size (font-size: xxx) or changing the font itself but the options do not have an effect. I do not get any error messages. It seems that the options that change the properties of the font itself are not applied to the component. I never made any changes to the overall theme so I guess I’m using the standard settings which should be the lumo-theme. To me it seems that the theme overwrites my changes in the .css style file. I tried !important at the end of the relevant properties but that did not work either.
If it is relevant, I use Vaadin 14.4.4 and Firefox 84.0.2.
It is actually not a huge issue for me. However, I want to get it to work just to understand how the different components of Vaadin and the other technologies work if I have to use it in the future again. Now I’m at the point where I cannot determine if I’m doing something terribly wrong or if there is some interaction which I do not understand, yet
It could be just specifity issue. Grid by default defines “font-weight: 500” for header-cell, thus you need to have a more specific css selector or use !important to overide it.
Tatu Lund:
It could be just specifity issue. Grid by default defines “font-weight: 500” for header-cell, thus you need to have a more specific css selector or use !important to overide it.
After using the content inspector of my browser and having a look at the applied CSS styles, I found the selector [part~="header-cell"] ::slotted(vaadin-grid-cell-content) which, as you said, indeed sets the font weight to 500 and the font size to var(–lumo-font-size-s). I guess, since this selector is more specific than [part~="header-cell"] , which I used before, it overwrites my settings, doesn’t it?
After I changed the selector in my CSS style file to [part~="header-cell"] ::slotted(vaadin-grid-cell-content) it worked!
So simple but I guess I needed your pointer to specific selectors …