Overview

Each example is self-contained and builds on the previous one. They all share the same base setup — a Form instance with four field types and a simple renderRoot.

Shared setup

The code below is the foundation for every example on this page. Field components follow the same contract: receive everything via useField, render UI, pass values back via onChange.

form.setup.tsx
InputField
TextAreaField
SelectField
CheckboxField
import { setupForm, defineMapping } from "react-headless-form";
import InputField from "./fields/InputField";
import CheckboxField from "./fields/CheckboxField";
import TextAreaField from "./fields/TextAreaField";
import SelectField from "./fields/SelectField";

export const [Form, defineConfig, Section] = setupForm({
  renderRoot: ({ children, onSubmit }) => (
    <div className="blueform-example">
      <form onSubmit={onSubmit}>{children}</form>
    </div>
  ),
  fieldMapping: defineMapping({
    text: InputField,
    longText: TextAreaField,
    checkbox: CheckboxField,
    select: SelectField,
  }),
});

export default Form;

Examples

#ExampleWhat it covers
1Login FormFlat model, basic validation, props passthrough
2Registration FormMultiple field types, cross-field validation, disabled as function
3Nested Formsection + nested: true, defineConfig, reusable config fragments
4Array Fieldsarray type, useArrayField, add / remove / duplicate
5Conditional Fieldsvisible as function, conditional validation with validate
6Computed FieldsonFieldChange + setValue for derived values — slug, BMI, full name
7Multi-step Wizardsection composition, shared RHF state across steps, Section component
Note

The forms in these examples are styled via shared CSS applied to the field components and wrapper. BlueForm itself is fully headless — it ships no styles, no UI primitives, and has no opinion on how your fields look.