Function

withCustomAddon

@ng-forge/dynamic-forms

Register a custom addon kind with the form.

The provided definition is added to ADDON_KIND_REGISTRY">ADDON_KIND_REGISTRY at form initialisation, alongside the built-in text / template / component kinds and any kinds contributed by adapter feature helpers (withPrimeNGAddons() etc.).

Signature

function withCustomAddon<
  T extends BaseAddon
>(definition: AddonKindDefinition<T>): DynamicFormFeature<"addons">

Type Parameters

NameConstraintDefaultDescription
TBaseAddon--

Parameters

NameTypeDescription
definitionAddonKindDefinition<T>-

Returns

DynamicFormFeature<"addons">

Examples

provideDynamicForm(
  ...withMaterialFields(),
  withCustomAddon({
    kind: 'lucide-icon',
    // Match how field types register: a default-exported component lets
    // `loadComponent` return the import promise directly.
    loadComponent: () => import('./lucide-icon-addon.component'),
    validate: (addon) => {
      if (typeof addon.icon !== 'string') {
        throw new Error('lucide-icon: icon string is required');
      }
    },
  }),
);