A form building tool built on the GOV.UK Prototype Kit that allows you to create and manage multi-page forms with various field types. Built with GDS design patterns and Defra styling.
- Create multi-page forms with an intuitive interface
- Support for multiple field types (text, textarea, radio, checkbox, select, date, etc.)
- Form preview with Previous/Continue navigation
- Custom Defra-styled header
- Modular JavaScript architecture with reusable components
- Live preview using PreviewManager module with official GDS markup
- Data persistence using StorageManager module and localStorage
- Full GDS component styling and accessibility features
- Clone this repository
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Visit
http://localhost:3000
in your browser
- Start at the Pages List (
/pages
) - Click "Add new page" to create your first page
- Add fields to your page using the field type options
- Configure each field's settings in the question editor
- See live previews rendered with GDS markup as you make changes
- Return to the Pages List to manage your pages
- Use the "Preview form" button to see your complete form
The tool uses a modular JavaScript architecture:
- PreviewManager: Handles real-time field previews using official GDS markup
- StorageManager: Manages data persistence and state management
- options.js: Manages field configuration and options
- pages.js: Handles page creation and management
- form-preview.js: Controls the complete form preview functionality
All field types are rendered using official GOV.UK Design System markup and classes.
- Text input (
govuk-input
) - Single line text - Text area (
govuk-textarea
) - Multi-line text - Email address (
govuk-input
) - With email format validation - Telephone number (
govuk-input
) - For phone numbers - Number (
govuk-input
) - For numeric input
- Radio buttons (
govuk-radios
) - Single selection from multiple options - Checkboxes (
govuk-checkboxes
) - Multiple selections allowed - Select dropdown (
govuk-select
) - Single selection from a dropdown list
- Date input (
govuk-date-input
) - For capturing dates with day/month/year fields - File upload (
govuk-file-upload
) - For file attachments
app/
├── assets/
│ ├── javascripts/
│ │ ├── modules/ # Core reusable modules
│ │ │ ├── preview-manager.js # Field preview with GDS markup
│ │ │ └── storage-manager.js # Data persistence
│ │ ├── application.js # Main application entry
│ │ ├── form-preview.js # Form preview functionality
│ │ ├── options.js # Field options management
│ │ └── pages.js # Page management
│ └── sass/
│ ├── application.scss # Main styles
│ └── legacy.scss # Legacy support
├── views/
│ ├── includes/ # Reusable view components
│ │ ├── _header.html # Custom Defra header
│ │ ├── _footer.html # Custom footer with docs
│ │ └── _option-list.html # Field options template
│ ├── layouts/
│ │ └── main.html # Base layout template
│ ├── pages.html # Page list/summary
│ ├── page-create.html # New page creation
│ ├── page-editor.html # Page content editor
│ ├── question-editor.html # Field configuration
│ ├── docs.html # Technical documentation
│ └── form-preview.html # Complete form preview
└── routes.js # URL routing
/pages
- Main page list and form summary/page-create
- Create a new page/page-editor/[pageId]
- Edit page and manage fields/field-types?pageId=[pageId]
- Choose field type to add/question-editor/new/[type]?pageId=[pageId]
- Create new field/question-editor/[type]/[id]?pageId=[pageId]
- Edit existing field/form-preview
- Preview complete form
This tool uses modern JavaScript features and the localStorage API. It should work in:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
To add a new field type to the form builder, you'll need to modify these files:
app/
├── views/
│ └── question-editor.html # Add field type and settings UI
└── assets/
└── javascripts/
├── modules/
│ └── preview-manager.js # Add GDS markup generation
└── options.js # Add field options handling
In question-editor.html
:
- Add the field type to the type selector
- Create field-specific settings section
- Use GDS classes for all form elements
In preview-manager.js
:
- Add case to the switch statement
- Use official GDS markup and classes
- Handle any field-specific attributes
In options.js
:
- Initialize field-specific settings
- Add data saving/loading logic
- Handle any special validation
See the technical documentation for detailed examples and best practices.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- GOV.UK Prototype Kit - The web framework used
- GOV.UK Design System - UI components and patterns
- Node.js - Runtime environment
- Express - Web application framework
This project is licensed under the MIT License - see the LICENSE file for details.
- GOV.UK Prototype Kit team
- GOV.UK Design System team
- Defra Digital team