This guide will help you set up and run the Forms Builder and Renderer system.
- Node.js (v18 or higher)
- Python 3.8+
- npm (comes with Node.js)
- Django 4.0+ (for backend)
From the root directory:
# Install all npm dependencies
npm installThis will install dependencies for all packages in the monorepo.
cd packages/backend
pip install -e .
# or
pip install -r requirements.txtnpm run dev:builderThen open http://localhost:5173 in your browser.
npm run dev:rendererThen open http://localhost:5173 in your browser.
npm run build:all# Build shared types
cd packages/shared
npm run build
# Build renderer
cd packages/renderer
npm run build
# Build builder
cd packages/builder
npm run buildAdd to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'forms_builder',
]Add to your urls.py:
from django.urls import path, include
urlpatterns = [
# ...
path('forms/', include('forms_builder.urls')),
]python manage.py migrate forms_builderpython manage.py createsuperuserpython manage.py runserverNavigate to http://localhost:8000/admin/ and log in with your superuser credentials.
-
Start the form builder development server:
npm run dev:builder
-
Design your form by dragging fields from the palette
-
Configure field properties in the right panel
-
Export the form definition JSON
-
Import the JSON into Django admin
-
Navigate to Forms Builder → Form Definitions
-
Click "Add Form Definition"
-
Use the visual form builder interface
-
Configure form settings
-
Save the form
-
Start the renderer development server:
npm run dev:renderer
-
Modify
index.htmlto load your form definition
<!DOCTYPE html>
<html>
<head>
<script type="module" src="path/to/@forms-poc/renderer/dist/index.js"></script>
</head>
<body>
<form-renderer id="my-form"></form-renderer>
<script type="module">
// Fetch form definition from Django
const response = await fetch('/forms/api/forms/contact-form/');
const { form } = await response.json();
// Set form definition
const formElement = document.getElementById('my-form');
formElement.definition = form;
// Handle submission
formElement.addEventListener('form-submit', async (event) => {
const response = await fetch('/forms/api/forms/contact-form/submit/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event.detail.data)
});
if (response.ok) {
alert('Form submitted successfully!');
}
});
</script>
</body>
</html>forms-poc/
├── packages/
│ ├── shared/ # Shared types and utilities
│ │ ├── src/
│ │ │ ├── types.ts
│ │ │ ├── validation.ts
│ │ │ └── logic.ts
│ │ └── package.json
│ │
│ ├── renderer/ # Form renderer (Lit Elements)
│ │ ├── src/
│ │ │ └── components/
│ │ ├── index.html
│ │ └── package.json
│ │
│ ├── builder/ # Form builder (Lit Elements)
│ │ ├── src/
│ │ │ └── components/
│ │ ├── index.html
│ │ └── package.json
│ │
│ └── backend/ # Django package
│ ├── forms_builder/
│ │ ├── models.py
│ │ ├── admin.py
│ │ ├── views.py
│ │ └── validation.py
│ └── setup.py
│
├── package.json # Root package.json (workspaces)
└── README.md
Forms can have multiple steps with navigation:
{
isMultiStep: true,
steps: [
{
id: 'step-1',
title: 'Personal Info',
fields: [...]
},
{
id: 'step-2',
title: 'Additional Details',
fields: [...]
}
]
}Fields and steps can have conditional logic using JSONLogic:
{
id: 'email-field',
type: 'email',
conditionalLogic: {
'==': [{ var: 'contact_method' }, 'email']
}
}This field will only show if contact_method equals 'email'.
Fields support multiple validation rules:
{
id: 'age',
type: 'number',
validation: [
{
type: 'required',
message: 'Age is required'
},
{
type: 'min',
value: 18,
message: 'Must be 18 or older'
}
]
}Make sure you've installed all dependencies:
npm installBuild the shared package first:
cd packages/shared
npm run buildMake sure you've added the app to INSTALLED_APPS and run migrations:
python manage.py migrate forms_builder- Explore the example forms in the demo pages
- Read the API documentation in each package's README
- Customize the styling to match your brand
- Add custom field types
- Implement NL Design System components for accessibility
- Create a visual JSONLogic builder UI
For issues and questions, please refer to the README files in each package directory.