'Easier way to style error message part of all vaadin components

I want to change the default style for all vaadin components which has errorMessage part. The only way i know is to use @CssImport(value="...", themeFor="...") annotation for each vaadin component I want to style. Is there any other easier, nicer ways to do it?

The reason why i want to do this: I want to increase the max-height css property from 5rem to 10rem (I wish i could edit this with a global css variable to any value) and add word-break: break-word property too, because some error message overflows both horizontaly and verticaly.

image with example of my problem

image with example of my solution



Solution 1:[1]

If you don't need to support older browsers like IE11 and pre-Chromium Edge, you can do that easily for all Vaadin components with the ::part() selector in a global stylesheet:

::part(error-message) {
  max-height: 10em;
  word-break: break-word;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rolf