Skip to content

Element

A raw HTML element. Useful for injecting arbitrary markup into the component tree when no higher-level component fits the need.

new Element("div", Map.of("style", "background-color: green;"), "Hola!")
new Element(String name, Map<String, String> attributes, String content)
PropertyTypeDefaultDescription
nameString—HTML tag name (e.g. "div", "span", "p")
attributesMap<String, String>—HTML attributes (e.g. style, class, data-*)
onMap<String, String>—Event handlers
contentString—Inner text or HTML content
styleString—Inline CSS
cssClassesString—CSS class names
Form.builder()
.title("Custom element")
.content(List.of(
new Element("div",
Map.of("style", "background-color: green; padding: 1rem; border-radius: 4px;"),
"Hello from a raw div!"
),
new Element("p",
Map.of("style", "color: red; font-weight: bold;"),
"Warning: this is a raw paragraph."
)
))
.build()
Element.builder()
.name("span")
.attributes(Map.of("class", "highlight"))
.content("Highlighted text")
.style("font-size: 1.2rem;")
.build()

attributes and content accept ${...} expressions, evaluated against the component’s state and data — the same interpolation used by labels and titles:

Element.builder()
.name("workflow-graph")
.attributes(Map.of("overlay", "${state.overlay}"))
.build()

Written as a literal, an attribute is part of the component tree and is delivered only when that tree is rendered — so it stops following a view that refreshes itself with a State, which carries values and no tree. Written as an expression it is a value, arrives with every update, and is applied to the existing element with setAttribute rather than by rebuilding it. See Custom web components.

Element gives full control over the rendered HTML but bypasses Mateu’s component model. Prefer purpose-built components when one is available.

See it live in the Explorer: Element & CustomComponent (escape hatches)