Integrations

BlueForm renders no UI. You connect your UI kit with small adapters: an adapter is a React component that calls useField() and renders one of your kit's inputs (the Guide calls it a field component). The config keeps the logic — rules, conditions, computed values — and its props are typed by your kit's own components.

New to BlueForm? Read the Quick start first; this page builds on it.

configlabels · i18nrulesJSON conditionscomputed valuesmodel · defaultsadaptersfields.tsxvia setupFormuseField()→ yourcomponentsMantineshadcn/uiAnt DesignMaterial UIyour design systemLogic: what the form doesPer library: how it looks (its typed props)

Connect your UI kit

Write an adapter per input type

One adapter per kind of input your forms use (text, select, checkbox…). It reads the field from useField() and hands it to your component:

import { Input, type InputProps } from "my-ui"
import { type AdapterProps, useField } from "react-headless-form"

// your component's props, minus what useField() provides, minus `error` (set below)
export type TextFieldProps = AdapterProps<InputProps, "error">

export function TextField(props: TextFieldProps) {
  const { value, onChange, onBlur, ref, label, description, errorMessage, required, disabled, readOnly } =
    useField()
  return (
    <Input
      {...props}
      ref={ref}
      label={label}
      hint={description}
      error={errorMessage}
      required={required}
      disabled={disabled}
      readOnly={readOnly}
      value={value ?? ""}
      onChange={(e) => onChange(e.target.value)}
      onBlur={onBlur}
    />
  )
}
  • Pass the value to onChange. Check what your component's change handler gives you — a value, a DOM event or an object — and extract the value (e.target.value, checked, e.value…).
  • Attach ref so the form can focus a field with an error.
  • AdapterProps removes what useField() provides (value, onChange, label, disabled, …) from your component's props; its second argument lists the props the adapter sets itself (here error), so a config cannot override them.

Register them

import { defineMapping, setupForm } from "react-headless-form"

export const [Form, defineConfig] = setupForm({
  renderRoot: ({ children, onSubmit }) => <form onSubmit={onSubmit}>{children}</form>,
  fieldMapping: defineMapping({ text: TextField, select: SelectField, checkbox: CheckboxField }),
})

The keys (text, select, checkbox) are the type values of your config. renderRoot draws the form itself (its layout, a submit button). array, section, inline and hidden are built-in types and need no adapter.

Write configs with your kit's props

A field's props are typed by its adapter, so each config speaks its kit's API:

Mantine
Ant Design
Material UI
email: { type: "text", label: "Email", props: { type: "email", leftSection: "@" } },
ticket: { type: "select", label: "Ticket", props: { data: [{ value: "student", label: "Student" }] } },

A prop the component does not have, or a wrong value, is a type error (see type-checks.tsx).

Render the form

Render Form inside your kit's provider, as you would any component:

<Form<Registration>
  config={config}
  defaultValues={{ ticket: "standard", guests: [] }}
  onSubmit={(data) => save(data)}
/>

Labels are plain strings unless you add i18n: with i18nConfig.t, labels, descriptions, placeholders and error messages are translated. Use the field's description for help text (translated, read with useField().description) and pass it to the library's prop, e.g. Mantine description or MUI helperText.

Ready-made: 12 libraries

The same registration form, built with each library. Each is a starting point for a kit that works the same way:

LibraryChange handler givesSetup
Mantinetext: event (e.currentTarget.value) · select: valueMantineProvider, @mantine/core/styles.css
shadcn/uiDOM events (native inputs)Tailwind
Ant Designtext: event · select: value—
Material UIDOM events (TextField select too)CssBaseline (optional)
Chakra UItext: event · checkbox: { checked }ChakraProvider
PrimeReacttext: event · Dropdown: e.value · checkbox: e.checkeda theme CSS, PrimeReactProvider
Arco Designvaluesits CSS, ConfigProvider for locale
Semi Designtext: value (event second) · checkbox: eventits CSS (semi-ui-19 for React 19)
TDesignvaluesits CSS, ConfigProvider for locale
animal-island-uitext: event · select: key · Switch: checkedits CSS
React-BootstrapDOM eventsbootstrap/dist/css/bootstrap.min.css
React Native WebonChangeText: text · Switch: valuealias react-native → react-native-web
What to copy from a demo
  • fields.tsx: the adapters, as is.
  • form.tsx: setupForm and the config. It imports useT and FORM_ID from the docs' demo stage: use your own i18n hook and drop the form id.
  • Not needed in your app: main.tsx and docs/integrations/shared/* (language switch, header submit button, error list, payload drawer).

The demos render Form with i18nConfig (t, validationTranslation) and formOptions={{ shouldUnregister: true }}, which drops hidden fields from the payload. With arrays, read pitfall 14 before keeping shouldUnregister.

What the demo form shows

Form: renderRoot draws the title, a responsive grid and the submit button.

FieldDemonstrates
name, emailrequired, pattern; translated messages and placeholder
ticketa select; its options go in props, in the library's shape (data, options, children)
studentIdJSON condition visible (student tickets only); left out of the payload when hidden, since the demos set shouldUnregister
promoCodeJSON condition disabled (not for student tickets)
guestsarray with maxLength: 3; each guest's name is required, with the error on its row
invoice → billinga checkbox showing a nested section with its own rules
totalcomputed value: ticket price + $100 per guest

Validation libraries

Zod, Valibot, ArkType and Yup (1.7+) implement Standard Schema: pass them to the schema prop. For Ajv (JSON Schema) or any other react-hook-form resolver, use formOptions.resolver. With a schema, field rules are not used; set required: true on a field to show its *. See the Schema example.

Contributing: running the demos locally

In docs/, pnpm dev starts the docs and the demos (Vite, port 5180); pnpm dev:docs or pnpm dev:demos starts one of them.