Skip to content

Renderer

The Renderer widget renders raw framework markup returned by a callback. Use it when you need to drop a small piece of bespoke UI inside a form — a heading, a summary block, a chart — without writing a full custom widget.

import { gui } from '@golemui/gui-shared';
import { html } from 'lit';
const formDef = [
gui.displays.display(
(api) =>
html`<h1>
Client Name: ${api.$form?.details?.clientName || 'unknown'}
</h1>`,
),
gui.inputs.textInput('details.clientName', {
label: 'Client Name',
placeholder: 'e.g. Jane Doe',
validator: { required: true, minLength: 2 },
}),
];

Type a name into the input below — the heading above it re-renders on every keystroke because the callback reads $form.details.clientName:

The Renderer widget takes a function as its only argument. There’s no JSON equivalent — JSON cannot serialize functions.

import { gui } from '@golemui/gui-shared';
const formDef = [
gui.displays.display(
(params) => (
<div className="summary">
<h2>Booking summary</h2>
<p>Customer: {params?.$form?.customer?.name}</p>
</div>
),
),
];

The callback receives a params object with $form (the live form data tree) and re-renders whenever any referenced path changes. Read what you need from $form and the widget will keep itself in sync.