Skip to content

Fluent components

The fluent API lets you build UI programmatically — composing components in code using builders and Java objects instead of relying only on annotations and field declarations.


Use the fluent API when:

  • you need dynamic layout or content based on runtime state
  • you want to compose complex UIs that annotations alone cannot express
  • you are building reusable component classes
  • you need fine-grained control over component properties

The declarative (annotation-based) and fluent approaches are composable — you can mix them freely.


A fluent page implements ComponentTreeSupplier and returns a Form (or any Component) from its component() method:

@Route(value = "/my-page", parentRoute = "")
public class MyPage implements ComponentTreeSupplier {
@Override
public Form component(HttpRequest httpRequest) {
return Form.builder()
.title("My page")
.content(List.of(
new Text("Hello world")
))
.build();
}
}

InterfacePurpose
ComponentTreeSupplierProvides the component tree — implement component()
ActionHandlerHandles action calls — implement handleAction()
ActionSupplierDeclares available actions — implement actions()
RuleSupplierDeclares client-side rules — implement rules()
ValidationSupplierDeclares validations — implement validations()
TriggersSupplierDeclares triggers — implement triggers()
ListingBackendPowers a data listing — implement search()
AppSupplierDefines a nested app with its own navigation — implement getApp()

A class can implement as many of these as needed.


If you are new to the fluent API, start with Fluent API basics, then follow the topics in order: layouts and form fields for structure, actions and triggers for behavior, then listings and nested apps for larger screens.


  • Fluent API basics — ComponentTreeSupplier, Form, state management (6 counter patterns)
  • Layouts — HorizontalLayout, VerticalLayout, TabLayout, AccordionLayout, SplitLayout, BoardLayout
  • Form fields — FormField, FieldDataType, FieldStereotype
  • Actions — foreground, background, SSE, confirmation, href, JS, custom events
  • Rules — visibility, enabled, style, CSS class, data value, run action, run JS
  • Triggers — OnLoad, OnValueChange, OnSuccess, OnError, OnCustomEvent
  • Validations — required, conditional, form-wise, min/max, pattern, server-side
  • Commands and messages — CloseModal, SetWindowTitle, SetFavicon, RunAction, Dialog
  • Listings — Listing.builder(), columns, filters, sorting, row actions
  • Nested apps — AppSupplier, AppVariant, menu on left/top/tabs
  • Display components — Badge, Card, Chart, Grid, Map, Dialog, Avatar, Status, Amount