Skip to content

Layout and composition

Mateu composes page layout from three orthogonal concerns: structure (layout type), placement (regions and fieldsets), and constraints (inline style). All are declared with annotations — no template files required.

When to use: reach for layout annotations when the default vertical stacking of fields is not enough, or when you want to enforce consistent width and centering across pages.


Apply a layout annotation to a class or a nested section. Available options:

AnnotationEffect
@SectionStack sections top to bottom (default)
@Zones / @ZoneArrange sections side by side, in columns
@FormLayoutResponsive multi-column form grid
@MasterDetailMaster/detail panel
@FoldedLayoutSections side by side (one column each)
@TabTabbed sections
public class UserEditorPage {
@Tab("Personal") PersonalInfo personalInfo;
@Tab("Contact") ContactDetails contact;
@Tab("Roles") RolesSection roles;
}

Consecutive fields sharing a @Tab name become one tab. Mateu renders the container and wires navigation between sections.


@Style applies an inline CSS string to the root element of the page. The most common use is constraining width and centering content:

public class StyleConstants {
public static final String CONTAINER = "max-width:900px;margin: auto;display: block;";
public static final String FULL_WIDTH = "width: 100%;";
// also FULL_WIDTH_WITH_PADDING and COMPACT
}
@Style(StyleConstants.CONTAINER)
public class UserDetail {}
src/main/resources/specs/ui/routes.yaml
type: Routes
routes:
- route: users/:id
viewModel: com.example.UserDetail

Define the constants once and reuse them across pages to keep widths consistent.


Fields in a form grid default to one column. Use @Colspan to let a field span the full row:

@Colspan(2)
String notes;

This works inside any class rendered with @FormLayout.


Layout annotations compose with field rules. A @Hidden field still occupies no space; a field with @Colspan(2) widens only when it is visible.

public record ProductForm(
String sku,
int quantity,
boolean hasVariants,
@Colspan(2) @Hidden("!state.hasVariants") String variantNotes
) {}

  • Layout annotation — controls how top-level sections or nested classes are arranged
  • @Style — CSS string applied to the page root; use shared constants to keep it consistent
  • @Colspan — makes a form field span multiple grid columns