var error = new Span("Input required!");
error.addClassNames(LumoUtility.TextColor.ERROR);
add(error);
This however, doesn’t work.
To make it work, I had to explicitly add @StyleSheet(Lumo.UTILITY_STYLESHEET) on my Application class
How do I make sense of this, considering the compiler had no problem in loading the LumoUtility class?
I am thinking on the lines that if the class was loaded, shouldn’t the associated resources like stylesheet be automatically loaded?
It would be great if the stylesheet could be automatically loaded if the LumoUtility class is used in any way. If I recall correctly, that is not possible because the class is never instantiated since you only ever refer to static constants and nested classes inside it.
(Previously, the stylesheet was loaded by including it in the lumoImports property in theme.json, but in V25 that is no longer supported: Utility Classes)
Yes, and we attempted to change that in the past with a solution that looked trivial by first glance
But that was found out too significant breaking change
Naturally this is something that could have been taken as breaking change to Vaadin 25, but not re-evaluated. This does not apply just LumoUtility, but any solution what we may plan as Java API for TailWind utilities.