Skip to main content

Fields

Fields are the building blocks of your forms in react-form-krafter.

They are reusable components that encapsulate the logic and UI for a specific type of input.

Using a registered field

Your field will look like this:

src/components/fields/fieldExample.js
export const BaseField = {
name: "string",
label: "string",
initialValue: undefined,
required: false,
placeholder: "string",
disabled: false,
options: [],
type: "text", // or "number", "select", etc.
};

Properties

NameDescriptionRequired
nameA unique identifier for the field.
labelText label displayed alongside the field in the UI.
initialValueThe default value assigned when the form is first rendered.
requiredMarks the field as mandatory for submission.
placeholderHint text shown inside the input when it's empty.
disabledWhether the field starts as disabled and not editable by the user.
optionsAn array of { label, value } pairs used for select, radio, or similar field types.
typeDefines the field's type (e.g., "text", "number", "select"), which maps to the registered component.