Skip to content

Widget Loaders

Widget loaders are a Record<string, () => Promise<unknown>> map that tells the form engine how to lazy-load each widget kind. The map key is the widget type (e.g. 'textinput', 'dropdown') and the value is an async loader that returns the widget implementation.

Each framework adapter exports a widgetLoaders object preloaded with the GolemUI widget set:

import * as React from '@golemui/gui-react';
// React.widgetLoaders covers every built-in input, layout, display, and action widget.

Pass this as part of formConfig:

const formConfig = { widgetLoaders: React.widgetLoaders };

Spread the defaults and add your own custom widgets to the same map:

const formConfig = {
widgetLoaders: {
...React.widgetLoaders,
productCard: async () =>
(await import('./widgets/ProductCard')).ProductCard,
},
};

The type key in the loader (productCard) must match the type field in your widget definitions.