define() call on a plain React function. No provider, no class extension, no parallel schema, no widget registry β the component is immediately addressable from JSON, participates in data binding and validation, and works in the visual Designer automatically.
The 10-line story
This is the entire surface area of registering a valued custom input that reads and writes form data:myInput.model to your view (createView([myInput.model, ...])) and the component is now a first-class citizen of the form:
- Any JSON schema can reference it as
"type": "MyInput". - Data binding is automatic because
value: string.valuedmarks the bound property. - The FormEngine Designer picks it up in the component palette β non-developers can drag it into forms.
- Validation, error display, conditional logic, and events all work without extra wiring.
What Are Custom Components?
Custom components are React components that you wrap with FormEngineβs define function to make them available in the form viewer. Once defined, they can be used in JSON form definitions just like built-in components. Example: Simple Custom Buttonlive
Why Create Custom Components?
1. Unique UI Requirements
Your application may need specialized UI elements that arenβt available in standard component libraries.2. Business Logic Encapsulation
Embed business logic directly in components for consistency.3. Third-Party Integration
Wrap third-party React components to use them in your forms.4. Consistent Branding
Ensure all form elements match your design system.Component Development Journey
This guide will walk you through creating custom components of increasing complexity:π Section 1: Getting Started
- Setting up your development environment
- Creating your first simple component
- Understanding the
define()function - Adding components to your view
π Section 2: Simple Components
- Components without data binding
- Working with basic props (string, number, boolean)
- Adding visual customization (CSS, styling)
- Component categories and organization
π Section 3: Valued Components (Data Binding)
- Understanding data binding concepts
- Creating components that read/write form data
- Using
valuedproperties - Two-way data synchronization
π Section 4: Components with Events
- Handling user interactions
- Creating custom events
- Event parameters and data
- Common action integration
π Section 5: Components with Validation
- Adding validation rules to components
- Displaying validation errors
- Custom validation logic
- Validation schemas
π Section 6: Advanced Patterns
- Composite components (components with children)
- Accessing form context
- Cross-component communication
- Performance optimization techniques
π Section 7: Component Lifecycle
- Mount/unmount events
- Data change detection
- Cleanup and resource management
- Using React hooks with FormEngine
π Section 8: Styling Custom Components
- Inline styles vs CSS classes
- Responsive design
- Theme integration
- CSS-in-JS approaches
π Section 9: Testing
- Unit testing components
- Integration testing with forms
- Mocking form context
- Test utilities and helpers
Prerequisites
Before creating custom components, you should be familiar with:- React fundamentals (components, props, hooks)
- TypeScript basics (types, interfaces)
- FormEngine Core concepts (forms, views, data binding)
Getting Help
If you get stuck:- Check the package typings and source docs for detailed API information
- Review Component Library for built-in component examples
- Look at the source code on GitHub
- Ask questions in GitHub Discussions
Next Steps
Ready to start? Use the examples in this guide to create your first custom component.Documentation Structure:
- Getting Started β Basic setup and first component
- Simple Components β Static, display-only components
- Valued Components β Components with data binding
- Components with Events β Interactive components
- Components with Validation β Validated components
- Advanced Patterns β Complex component patterns
- Component Lifecycle β Lifecycle management
- Styling β Visual customization
- Testing β Quality assurance