Public API
ErlForm props, low-level components, and runtime exports.
ErlForm
import { ErlForm } from "erlangform";
<ErlForm<Values>
form={form}
schema={schema}
fieldConfig={fieldConfig}
sectionConfig={sectionConfig}
fieldComponent={registry}
wizard={wizard}
serverErrors={serverErrors}
onValuesChange={handleValuesChange}
/>This lists all props; only form and schema are required. Initialize variables as described in their feature guides.
| Prop | Type or role |
|---|---|
| form | ReactFormExtendedApi from TanStack useForm |
| schema | z.ZodObject; provides renderer metadata |
| fieldConfig | FieldConfig for presentation and behavior |
| fieldComponent | ComponentRegistry for type-based overrides |
| sectionConfig | SectionConfigs keyed by section name |
| wizard | FormWizardOptions for steps |
| serverErrors | Record of paths to strings or readonly string arrays |
| onValuesChange | Complete values callback, including on mount |
ErlForm has no children, onSubmit, defaultValues, className, or theme prop in 1.0.0. useForm handles submission and defaults; the application supplies the HTML wrapper. AutoForm is the internal implementation name, not a public component export.
For serverErrors, read the TanStack compatibility note. The demo mirrors errors into errorMap.onServer because the prop alone does not populate derived errors with the installed TanStack version.
Field
A low-level single-field component. Required props: form, name, type, state. Optional props: config, fieldComponent, values. type refers to inferred metadata such as string/number/boolean; password/textarea belong to config.type.
import { Field } from "erlangform";
<Field form={form} name="name" type="string"
state={{ visible: true, disabled: false, readOnly: false, required: false }}
config={{ label: "Name" }} />Field renders the control, label, description, and error. It does not process showIf, clearOnHide, layout, or recursive containers like FieldRenderer does. Supply effective state yourself.
FieldRenderer and infer
Form values
[
{
"name": "name",
"type": "string"
},
{
"name": "active",
"type": "boolean"
},
{
"name": "email",
"type": "email"
}
]Select a schema to inspect the actual metadata from infer.
Use your form instance from useForm. See the initial setup.
const schema = z.object({
name: z.string(),
active: z.boolean(),
});
const fields = infer(schema);infer accepts z.ZodObject and returns FieldMeta[]. Each entry has name/type, with fields for objects, item for arrays/records, items for tuples, variants/discriminator/variantKeys for unions, and options for string choices. Metadata does not include all validation checks, schema bounds, or default values.
FieldRenderer takes form, field metadata, values, and optional fieldConfig, fieldComponent, parentPath, and legacyFieldConfig. When using it without ErlForm, subscribe to current values yourself, for example through form.Subscribe.
All public imports come from erlangform. FieldArray, FieldControl, FieldSection, AutoFormProps, SelectOption, and internal utilities are not exported. See public types; avoid src/dist subpath imports.