Build a Multi-Step Survey in 5 Minutes with FieldCraft
TL;DR — Define a multi-step survey as a single JSON schema. FieldCraft handles navigation, progress tracking, per-section validation, conditional fields, and draft persistence. You write zero form state code.
What We're Building
A three-step customer feedback survey with:
- Step 1: Contact info with email validation
- Step 2: Product feedback with ratings and conditional follow-up
- Step 3: Final comments with optional contact consent
Progress bar, back navigation, per-section validation, and conditional fields — all defined in one JSON schema. No useState, no form libraries, no validation wiring.
Setup
Install FieldCraft's core engine and React renderer:
The Schema
FieldCraft forms are defined as JSON schemas. A multi-step form uses the sections array — each section becomes one step. Let's build the schema piece by piece.
Form metadata and settings
The top-level object defines the form's identity and UX behavior:
Change progressStyle to "percentage" to show "67% complete" instead of "Step 2 of 3". Change "bar" for a visual progress bar. All three styles work with zero additional code.
Section 1 — Contact info
Each object in the sections array becomes one step in the multi-step flow. Users can't advance until all required fields in the current section pass validation.
Three fields: a text input, an email input with built-in format validation, and a dropdown. All required — the user must fill them in before moving to Step 2.
Section 2 — Product feedback
This section mixes field types: a star rating, an NPS score (0-10), a dropdown, and a long text area with a 500-character limit. The validation array on pain_point adds the maxLength constraint.
Section 3 — Final thoughts with conditional logic
Notice the showIf on preferred_contact — this field only appears when the user toggles can_contact to true. That's conditional logic, covered in detail below.
That's the entire form. Three sections, nine fields, conditional logic, validation rules, progress tracking, and back navigation — all from a single JSON object. No
useState, no event handlers, no validation wiring.
Validation
Required fields get validated automatically. For custom rules, add a validation array:
Built-in validators include minLength, maxLength, min, max, pattern (regex), and email. The email validator checks for a valid TLD — user@example.c is rejected, user@example.co is accepted.
Errors display on blur, not on every keystroke. Users finish typing before seeing validation feedback.
Conditional Fields
The showIf property controls field visibility based on other field values:
The "preferred contact" field only appears when the user toggles "Can we follow up?" to yes. The engine re-evaluates conditions on every value change.
Automatic cleanup: if a user fills in the conditional field, then toggles the parent back to "no", the hidden field's value is cleared. You never submit stale data from hidden fields.
Available operators
You can use any of these operators in showIf conditions and nest them with AND/OR groups for complex logic:
| Operator | Meaning |
|---|---|
eq / neq | Equals / not equals |
gt / lt | Greater than / less than |
gte / lte | Greater than or equal / less than or equal |
contains / notContains | String or array contains value |
startsWith / endsWith | String starts or ends with value |
in / notIn | Value is in / not in a list |
isEmpty / isNotEmpty | Value is empty / not empty |
Rendering
One component, one prop for the schema, one callback for submission:
The response.values object contains all field values keyed by field ID:
Draft Persistence
Long surveys risk abandonment. FieldCraft auto-saves progress to localStorage by default. If a user closes the tab and comes back within 72 hours, their answers are restored — including which section they were on.
Zero configuration. Draft persistence is on by default. Users pick up exactly where they left off — same section, same answers.
Theming
Import a theme preset and pass it to the theme prop:
Built-in presets: cleanPreset, darkPreset, modernPreset, highContrastPreset, clinicalPreset, playfulPreset. Or pass a custom FormEngineTheme object for full control over colors, spacing, borders, and typography.
Using a Pre-Built Template
Don't want to write the schema from scratch? FieldCraft ships 16 free templates:
That gives you a three-section feedback survey with NPS, Likert scales, ratings, conditional follow-up, and progress tracking — zero configuration.
Browse all 16 templates on npm or check the template catalog.
What's Next
This tutorial covers the basics. FieldCraft also supports:
- Computed fields — calculate values from other fields using expressions
- Custom validators — register your own validation logic
- Custom field types — build and register field components
- Storage adapters — save responses to Postgres, Supabase, or any webhook endpoint
- File uploads — with drag-and-drop and preview
Full docs at squaredr.tech/products/fieldcraft/docs.