@mrzr/react-form-builder

React forms from config, on react-hook-form.

A config says what a field holds, how it is validated, when it is shown, disabled or filled from other fields, and who may see it. Native HTML out of the box, or your own components, given once for the whole project.

npm install @mrzr/react-form-builder react-hook-form
Version
v0.1.3
Published
Nov 2026
License
MIT
Requirements
React 18 or newer (tested with 19) and react-hook-form 7.
Fieldstsx
export const fields: FormFieldConfig<Values>[] = [
  { type: "text", name: "title", label: "Title", required: true },
  {
    type: "text",
    name: "slug",
    label: "Slug",
    dependencies: [{
      kind: "watch",
      when: { field: "title", op: "filled" },
      then: {
        skipIfDirty: true,
        from: ({ title }) => String(title).toLowerCase().replaceAll(" ", "-"),
      },
    }],
  },
  { type: "email", name: "email", label: "Email", required: true },
];

<Form<Values> fields={fields} onSubmit={onSubmit} columns={2} submitLabel="Sign up" />

The slug follows the title until the user edits it.

Your components, oncetsx
export const { Form, FormBuilder, defineFields } = createFormBuilder({
  components: {
    wrapper: Field,
    fields: { text: IconText, rating: { component: Rating, label: "none" } },
  },
  defaults: { select: { clearable: true } },
  messages: { required: { en: "Please fill in {label}.", fa: "{label} را پر کنید." } },
});

What it does

25+ field types

Text to OTP, select and combobox, dates and ranges, sliders, files, segmented controls, custom fields and arrays.

Dependencies

visible, disabled, validate, options and watch rules that read other fields.

Validation from config

Required, lengths, ranges, patterns, file size, date bounds and messages in several languages, or a schema resolver.

Access and languages

A field with a permission only exists for users who have it. Texts resolve to the user’s language.

Field arrays and layout

Rows with add, remove, move and limits; a grid of columns with colSpan.

Jalali dates

Date fields that hold Jalali text, a date object or ISO, with the calendar functions exported.

Documentation

Everything is documented.

Start reading

More packages