Schema Reference
Complete reference for all TypeScript types exported by form-builder-types.
FormSchema
The root object passed to FormRenderer and emitted by FormBuilder.
| Field | Type | Description |
|---|---|---|
id* | string | Unique identifier for the form. |
title* | LocalizedString | Form heading, displayed above the fields. |
description | LocalizedString | Optional subtitle shown below the title. |
fields* | FormFieldDefinition[] | Ordered list of field definitions. Rendered in ascending order value. |
submitLabel | LocalizedString | Submit button label. Defaults to "Submit". |
settings | FormSchemaSettings | Layout and behavior overrides. |
FormFieldDefinition
Defines a single field in the form. Each entry in FormSchema.fields conforms to this type.
| Field | Type | Description |
|---|---|---|
id* | string | Internal identifier for the field (used for selection/reordering in the builder). Falls back to this as the form data key when key is not set. |
key | string | Stable, human-readable property name used as the form data key in the submitted object and JSON Schema. Not applicable to display-only fields (heading, paragraph, separator, pagebreak). |
type* | FormFieldType | The widget type. See Field Types below. |
label* | LocalizedString | Visible label for the field. |
order* | number | Sort order. Fields are rendered in ascending order. |
placeholder | LocalizedString | Input placeholder text. Applies to text, email, tel, number, textarea. |
description | LocalizedString | Helper text shown below the input. |
required | boolean | Marks the field as required. Adds JSON Schema required constraint. |
defaultValue | unknown | Initial value pre-filled in the form. |
options | FormFieldOption[] | Required for select and radio types. |
validation | FormFieldValidation | Validation constraints. See Validation below. |
condition | FormFieldCondition | Conditional display rule. Field is hidden unless the condition passes. |
Field Types
The 10 input types, their JSON Schema mapping, and notes on behavior.
| Type | Widget | JSON Schema | Notes |
|---|---|---|---|
text | Input (text) | type: "string" | General single-line text input. |
number | Input (number) | type: "number" | Numeric input. Supports min/max validation. |
email | Input (email) | type: "string", format: "email" | Validates email format automatically. |
tel | Input (tel) | type: "string" | Phone number input with type="tel" for mobile keyboards. |
select | Select (dropdown) | type: "string", enum: [...] | Requires options. Uses shadcn Select component. |
checkbox | Checkbox | type: "boolean" | Single boolean toggle. Submits true/false. |
radio | RadioGroup | type: "string", enum: [...] | Requires options. Each option renders as a radio button. |
date | Input (date) | type: "string", format: "date" | Native date picker. Submits ISO 8601 date string. |
textarea | Textarea | type: "string" | Multi-line text. Supports minLength/maxLength. |
file | Input (file) | type: "string", format: "data-url" | File picker. Value is a base64 data URL. |
Display fields — heading, paragraph and separator — render a heading, a paragraph (from label) and a divider. They collect no data and are excluded from submitted form data. pagebreak is a layout field that starts a new page; see Pages.
LocalizedString
LocalizedString is string | Record<string, string>. Use a plain string for single-language forms; use a locale map for multi-language forms.
Resolution order: active locale → baseLocale → first available key → empty string.
Validation
The validation field accepts a FormFieldValidation object.
| Field | Type | Applies to | Description |
|---|---|---|---|
minLength | number | text, email, tel, textarea | Minimum character count. |
maxLength | number | text, email, tel, textarea | Maximum character count. |
min | number | number | Minimum numeric value. |
max | number | number | Maximum numeric value. |
pattern | string | text, tel | Regex pattern the value must match. |
customRule | string | all input types | Key referencing a validator registered via registerValidator. |
Custom validators
Register a validator once (at app startup) and reference it by key in any field's validation.customRule.
Conditions
Set condition on a field to make it conditionally visible based on another field's current value.
Operators
| Operator | Description | value required? |
|---|---|---|
eq | Strict equality (===) | Yes |
neq | Strict inequality (!==) | Yes |
gt | Greater than. Numeric comparison. | Yes |
lt | Less than. Numeric comparison. | Yes |
contains | String includes the value. | Yes |
empty | Field value is empty, null, or undefined. | No |
notEmpty | Field value is not empty. | No |
Values of hidden fields are left out of the data passed to onChange and onSubmit. Conditions can chain: if a field depends on one that is hidden, it is hidden too. When a field is shown again, the value the user typed earlier comes back.
Pages
Add a pagebreak field to split a long form into pages. Fields before the first break form page 1, and each break starts the next page. The break's label and description become that page's title and subtitle; an empty label falls back to the form title.
- Next validates only the current page. Back never validates, and values are kept when moving between pages.
- On submit, every visible field is validated again. If a field on an earlier page fails (for example, a condition made it required after that page was passed), the form goes back to that page and shows the error.
- Submitted data stays flat — pages don't nest it.
toJsonSchemaandtoUiSchemaskip page breaks, so the JSON Schema of a paged form is the same as without pages. - Pages left empty, for example because every field on them is hidden by a condition, are skipped.
Settings
FormSchemaSettings is an optional object on the root FormSchema. Fields marked planned are part of the type, but FormRenderer does not act on them yet. Track progress in the changelog.
| Field | Type | Default | Description |
|---|---|---|---|
layoutplanned | "vertical" | "horizontal" | "vertical" | Controls label position relative to the input. |
showProgressBar | boolean | false | Multi-page forms only. Shows a progress bar under the page counter. |
nextLabel | LocalizedString | "Next" | Multi-page forms only. Label of the button that goes to the next page. |
backLabel | LocalizedString | "Back" | Multi-page forms only. Label of the button that goes to the previous page. |
successMessageplanned | LocalizedString | — | Message shown after successful submission (if provided). |