Overview
The Visual Editor is the core component of the HubSpot Form Builder, providing an intuitive drag-and-drop canvas where you can design multi-step form layouts. Built with@dnd-kit/core, it offers a flexible row-based layout system that lets you organize fields exactly how you want them.
The editor is implemented in
main/frontend/src/components/LayoutBuilder.tsx and uses Zustand for state management through useLayoutStore.Key Features
Drag-and-Drop
Intuitive field arrangement with visual feedback and smooth animations
Row-Based Layout
Organize up to 3 fields per row for flexible form designs
Multi-Step Support
Create unlimited steps with independent field groups
Real-Time Preview
See changes instantly in the preview panel
Canvas Structure
Steps
The canvas organizes your form into steps, which are the top-level containers in a multi-step form:- Title: Editable inline (line 89-95 in LayoutBuilder.tsx)
- Rows: Container for field groups
- Delete button: Available when you have more than one step
Rows
Rows are the building blocks of your layout. They can contain 1 to 3 fields and automatically adjust their width:Rows automatically distribute space evenly between fields. A row with 2 fields will display them at 50% width each, while 3 fields display at approximately 33% width each.
Fields
Fields are the individual form elements. Each field displays:- Drag handle (⋮⋮): For reordering within the canvas
- Label: From the HubSpot form schema
- Required badge: For required fields
- Delete button: For optional fields only
Step Management
Creating Steps
- Single-Step Mode
- Multi-Step Mode
In single-step mode, your form has only one step and all fields appear on a single page:This is ideal for simple forms with fewer than 10 fields.
Renaming Steps
Click directly on the step title to edit it inline:Deleting Steps
You can delete any step except the last one. When a step is deleted:- All fields in that step return to the field palette
- The step is removed from the layout
- Navigation automatically adjusts
Field Arrangement
Adding Fields to the Canvas
There are several ways to add fields:From the Field Palette
Drag a field from the sidebar and drop it onto any step. See Field Palette for details.
Reordering Fields
Fields can be reordered in three ways:Drop Zones
The editor provides visual feedback for valid drop zones:- Top zone (before row): Creates a new row above
- Center zone (inside row): Adds to existing row (max 3 fields)
- Bottom zone (after row): Creates a new row below
Visual Feedback
Drag State
While dragging, the editor provides visual cues:- Dragging item: 50% opacity
- Drop zones: Highlighted with borders
- Hover state: Background color changes
- Drag overlay: Ghost image follows cursor
Empty States
When a step has no fields:Technical Implementation
Component Architecture
The visual editor uses a hierarchical component structure:State Management
The editor uses Zustand for state management:Drag-and-Drop System
Implemented with@dnd-kit/core and @dnd-kit/sortable:
The DnD system distinguishes between three data types:
type: 'step'- For reordering stepstype: 'field'- For fields within the canvastype: 'palette-field'- For fields from the sidebar
Best Practices
Optimal Row Layout
Optimal Row Layout
- 1 field per row: Best for important fields like email or phone
- 2 fields per row: Good for related fields like first/last name
- 3 fields per row: Use for compact forms, but test on mobile
Step Organization
Step Organization
- Group related fields together in the same step
- Keep steps to 5-8 fields maximum for better completion rates
- Put the most important fields in the first step
- Save optional fields for later steps
Field Ordering
Field Ordering
- Follow a logical flow (e.g., personal info → company info → preferences)
- Place required fields at the top of each step
- Group similar field types together (e.g., all checkboxes together)
Keyboard Shortcuts
Keyboard shortcuts coming soon! Currently, the editor is mouse/touch-only.
Related Documentation
- Field Palette - Learn about the field palette and dragging fields
- Preview Panel - Test your form in real-time
- Module Export - Export your layout to HubSpot
