Form Builder
A visual drag-and-drop form builder that outputs FieldCraft schemas. 28 field types, undo/redo, keyboard shortcuts, and theming out of the box.
Install
Basic Usage
Styles: You must import @squaredr/fieldcraft-pro/styles.css for the builder UI to render correctly.
Props
| Prop | Type | Description |
|---|---|---|
initialSchema | FormEngineSchema | Schema to load on mount. Defaults to an empty form. |
onChange | (schema) => void | Called on every schema change |
onSave | (schema) => void | Called when user clicks Save or presses Ctrl+S |
height | string | number | Container height |
theme | FormBuilderTheme | Theme overrides via CSS variables |
toolbarExtra | ReactNode | Extra content in the toolbar (e.g., a Preview toggle) |
Adding a Preview Mode
The toolbarExtra prop lets you inject custom controls into the toolbar. A common pattern is adding a Builder/Preview toggle that swaps between the drag-and-drop canvas and a live FormEngineRenderer:
Theming
Two built-in presets are available:
You can also pass a custom FormBuilderTheme object with any combination of CSS color values for background, foreground, primary, accent, border, and builder-specific surfaces.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+S | Save |
Ctrl+Z | Undo |
Ctrl+Shift+Z | Redo |
Delete | Remove selected field or section |
Ctrl+D | Duplicate selected |
Persistence
The FormBuilder does not handle persistence itself. Use the onSave callback to send the schema to your backend. The schema output is a standard FormEngineSchema JSON object that works with any REST API, database, or the built-in adapters from @squaredr/fieldcraft-core.