Skip to main content
rule

react-formengine-ai-form-builder — Cursor rule

A Cursor rule that has the agent build React forms from a screenshot, PDF, HTML or text description and return a FormEngine JSON schema plus a runnable App.tsx.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/react-formengine-ai-form-builder-cursorrules-prompt-file.mdc
Open on GitHub

What react-formengine-ai-form-builder-cursorrules-prompt-file does

The rule pins down what the agent must hand back: form.json with a FormEngine schema checked against the component types of the chosen UI library, and App.tsx that imports the schema and renders it through <FormViewer>. A short validation report and an install command come with it. The schema is portable data, not throwaway JSX.

Inside is a list of schema invariants. The root is always type: "Screen", every node carries a key and a type that exists in the target library, and prop values are wrapped as { "value": "Email" }. Validation rules sit in schema.validations on the field that owns the data, never on the root. Styling stays at the layout level: css and wrapperCss take flex, grid, spacing and sizing, while colour, fonts and shadows belong in the library's theme provider in App.tsx. The legacy style field is off limits, and so is any HTML markup inside strings.

By default the rule targets FormEngine Core under MIT through @react-form-builder/core and @react-form-builder/components-rsuite; Material UI and Mantine come in when the user names them. Premium components such as Signature or DataGrid should not appear unless asked for directly. Validation keys come from the Zod set only: there is no minLength or maxLength, so min and max with args.limit are used instead.

What it helps with

  • turn a design screenshot into a working form
  • get a FormEngine JSON schema instead of scattered JSX
  • port an HTML form to RSuite components
  • check validation keys against the Zod set
  • render the schema in React through <FormViewer>

Example prompts for the agent

  • Build a signup form from signup.png using RSuite
  • Generate form.json and App.tsx for an order form with email and phone fields
  • Convert this HTML form into a FormEngine schema on Mantine

How to install react-formengine-ai-form-builder-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/react-formengine-ai-form-builder-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about react-formengine-ai-form-builder-cursorrules-prompt-file

How do I install react-formengine-ai-form-builder in Cursor?

Place the rule file at .cursor/rules/react-formengine-ai-form-builder-cursorrules-prompt-file.mdc inside your project. Cursor then applies it to files matching **/*.

What does this rule do?

It makes the agent output a FormEngine JSON schema and a runnable App.tsx rather than free-form JSX, along with a short schema check.

Which UI libraries are supported?

RSuite is the default and has the widest component set, including RsWizard for multi-step forms. Material UI and Mantine are used when the user mentions them or needs a Mantine-only component.

Source text

react-formengine-ai-form-builder-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for generating React forms from screenshots, PDFs, HTML, or text descriptions with validated FormEngine JSON schema. Renders through RSuite, Material UI, or Mantine."
globs: **/*
alwaysApply: false
---
# FormEngine — AI Form Builder for React

Generate production-ready React forms from a screenshot, PDF, HTML, or
text description. The output is a validated FormEngine JSON schema plus
a runnable App.tsx — portable data, not throwaway JSX.

Default target: FormEngine Core (MIT, free) via `@react-form-builder/core`
+ `@react-form-builder/components-rsuite` (or Material UI / Mantine).

Source repo: https://github.com/lukinov/ai-form-builder

## What you produce — every time

1. `form.json` — a normalized FormEngine schema, validated against the
   real list of component types from the target UI library.
2. `App.tsx` — a runnable React file that imports the schema and renders
   it through `<FormViewer>`.
3. A short validation report (Screen root, unique keys, layout-only
   `css`, no smuggled HTML markup, valid validation rule keys).
4. Install command + a link to the free Online FormBuilder
   (https://formbuilder.formengine.io) so the user can tweak visually.

## Hard rules — never violate

### Schema invariants

- Root is `type: "Screen"` (NOT `"Form"`).
- Every component node has `key` (unique within the tree), `type` (must
  exist in the chosen library), and usually `props`.
- **Every prop value is wrapped:** `"label": { "value": "Email" }` —
  never `"label": "Email"`.
- Validations live under `schema.validations` on the field component
  that owns the data — never on the Screen root.
- Use the correct tooltip/error types:
  - RSuite: `RsTooltip` / `RsErrorMessage`
  - MUI: `MuiTooltip` / `MuiErrorWrapper`
  - Mantine: `MtTooltip` / `MtErrorWrapper`

### Layout vs. styling

- `css` and `wrapperCss` are **layout-only** — flex, grid, box-model,
  margin, padding, gap, width/height, alignment. **Never** color, font,
  background, border, shadow, radius, opacity, transform.
- Visual styling belongs in the UI library's theme provider in
  `App.tsx` (`<CustomProvider>` / `<ThemeProvider>` / `<MantineProvider>`).
- The legacy `style` field is **forbidden** — use `css` / `wrapperCss`.
- The shape is `{ "any": { "object": { "<layout-key>": "<value>" } } }`,
  never a plain CSS string.
- No companion `.css` file alongside `App.tsx`. No root `className`. No
  `<style>` blocks. No `styled-components`.

### Plain-text strings only

Every string inside any prop is plain text. **No HTML markup of any
kind**, anywhere — no `<h1>`, `<p>`, `<strong>`, `<small>`, `<br>`, no
`style="..."`, no `class="..."`, no `<style>` block. Express section
headings and structure with components (`RsCard` with `header` prop,
`RsHeader`, `RsDivider`) — not embedded HTML.

### Validation rule keys — Zod set only

Valid keys: `required`, `nonEmpty`, `min`, `max`, `length`, `email`,
`url`, `uuid`, `ip`, `datetime`, `regex`, `includes`, `startsWith`,
`endsWith`, `lessThan`, `moreThan`, `integer`, `multipleOf`, `truthy`,
`falsy`. There is **no `minLength` / `maxLength`** — use `min` / `max`
with `args.limit`.

## UI library defaults

- **Default to RSuite.** Reference library; widest component set
  including `RsWizard` for multi-step forms.
- **Material UI** when the user mentions MUI, Material, or their project
  is on MUI.
- **Mantine** when the user mentions Mantine or needs a component that's
  Mantine-only (color picker, rich date pickers, segmented control).

State the choice explicitly in the first sentence of the response.

## Common renames — always emit the right name

| Wrong | Right |
|---|---|
| `Form` | `Screen` |
| `RsForm` | `RsCard` or `RsContainer` |
| `RsSelectPicker` | `RsDropdown` |
| `RsRadio` | `RsRadioGroup` |
| `RsTextarea` | `RsTextArea` (capital A) |
| `RsInputNumber` | `RsNumberFormat` |
| `RsUpload` | `RsUploader` |
| `MtDatePickerSingle` | `MtDatePicker` |
| `MtTextField` | `MtTextInput` |

## Side-by-side fields

Use `RsContainer` with `display: flex` and children with
`wrapperCss.any.object.flex: "1"`. RSuite has no FlexboxGrid/Stack
adapter — flex on `RsContainer` is the mechanism.

## Section headings

Use `RsCard` with the `header` prop, or `RsHeader` — never `<h1>` /
`<h2>` embedded in `RsStaticContent` `content` strings.

## Conditional rendering

Use `renderWhen: { "jsCode": "data.X === Y" }` and pair with
`validateWhen` if validations should also be conditional.

## App.tsx — minimal starter

Import only the library's stylesheet. Theme via the library's provider.
No companion CSS. No root className. Layout-level inline styles
(`maxWidth`, `margin`, `padding`) on the wrapping `<div>` are fine.

```tsx
import "rsuite/dist/rsuite.min.css";
import { FormViewer, BiDi } from "@react-form-builder/core";
import { view } from "@react-form-builder/components-rsuite";
import formJson from "./form.json";

const getForm = () => JSON.stringify(formJson);

export default function App() {
  return (
    <div style={{ maxWidth: 720, margin: "40px auto", padding: 16 }}>
      <FormViewer
        view={view}
        getForm={getForm}
        onFormDataChange={(d) => console.log(d)}
        biDi={BiDi.LTR}
      />
    </div>
  );
}
```

## Free vs. commercial — stay on the MIT side

FormEngine **Core** is MIT and free. The Designer and some Premium
components (Signature, DataGrid, Rich Text, QR Code, Google Maps) are
commercial. Don't emit Premium component types unless the user
explicitly asks. Direct people to the free Online FormBuilder
(https://formbuilder.formengine.io) for visual editing.

## Response shape

Lead paragraph (library + field count) → `form.json` → `App.tsx` →
validation checklist → install command → "tweak visually in the Online
FormBuilder" link → 3 next-step doc links into FormEngine Core docs.

## Reference

- FormEngine Core docs: https://formengine.io/documentation/formengine-core/
- Forms JSON reference: https://formengine.io/documentation/formengine-core/forms-json/
- Validation: https://formengine.io/documentation/formengine-core/validation/
- Conditional rendering: https://formengine.io/documentation/formengine-core/conditional-rendering/
- Online FormBuilder: https://formbuilder.formengine.io
- llms-full.txt (full machine-readable docs): https://formengine.io/documentation/llms-full.txt
- Source repo for this rule: https://github.com/lukinov/ai-form-builder

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

react-native-expo-router-typescript-windows-cursorrules-prompt-file This rule guides React Native projects using Expo, TypeScript, and Expo Router. It also covers NativeWind and Tailwind CSS versions, Babel configuration, and Windows terminal commands. ★ 41,024repo stars react-native-expo-cursorrules-prompt-file A Cursor rule that tells the agent how to write React Native code with Expo. Useful when you want new screens and components to follow one stack. ★ 41,024repo stars react-mobx-cursorrules-prompt-file Cursor rule for building React apps with MobX. It configures state stores, hook conventions, and strict MobX patterns for code generation. ★ 41,024repo stars react-graphql-apollo-client-cursorrules-prompt-file This rule guides React work with GraphQL and Apollo Client in Cursor. Use it when a project needs consistent patterns for operations, hooks, and error states. ★ 41,024repo stars react-components-creation-cursorrules-prompt-file Guides React component creation in Cursor by checking for duplicates, building v0.dev generation links, and standardising shadcn/ui imports. ★ 41,024repo stars react-chakra-ui-cursorrules-prompt-file A Cursor rule for React projects using Chakra UI, covering component style, theming, responsive layouts, accessibility, and project structure. ★ 41,024repo stars rails-cursorrules-prompt-file A Cursor rule file that tells the agent how to write Rails 8 code: generators, bin/dev, the Solid stack, Minitest and Hotwire. ★ 41,024repo stars r-cursorrules-prompt-file-best-practices Enforces R project structuring, tidyverse formatting standards, renv lockfiles, and package documentation guidelines in Cursor. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor