Styling Annotations
@Style (Target: TYPE, FIELD, PARAMETER)
Section titled “@Style (Target: TYPE, FIELD, PARAMETER)”public @interface Style { String value(); // inline CSS string}Applies inline CSS to the component’s root element. Applied on a class, styles the page container.
Example from the demo:
@UI("/home")@Style("max-width: 900px; margin: auto;")public class Home { ... }@CssClasses (Target: TYPE, FIELD, PARAMETER)
Section titled “@CssClasses (Target: TYPE, FIELD, PARAMETER)”public @interface CssClasses { String value(); // space-separated class names}Adds CSS class names to the component’s root element.
@DivStyle (Target: TYPE, FIELD, PARAMETER)
Section titled “@DivStyle (Target: TYPE, FIELD, PARAMETER)”public @interface DivStyle { String value(); // inline CSS string}Applies inline CSS to the wrapper <div> around the element, rather than the element itself. Useful when you need to style the layout container rather than the component.
StyleConstants
Section titled “StyleConstants”Mateu provides a StyleConstants class with predefined style values:
// Common usage@Style(StyleConstants.CONTAINER) // centers content with max-widthDifference between @Style and @DivStyle:
| Annotation | Styled element |
|---|---|
@Style | The component element itself |
@DivStyle | The outer wrapper div |