- How FormEngine Core automatically determines the view mode based on screen width
- How to manually control the view mode using the
viewModeprop - How to create device-specific styles using
cssandwrapperCssproperties - How to build responsive forms that adapt to different screen sizes
Overview
FormEngine Core’s adaptive layout system works by:- Automatically detecting screen width when no
viewModeprop is provided - Applying device-specific styles defined in your form JSON
- Supporting manual override when you need to test or lock a specific view mode
Automatic View Mode Detection
When you useFormViewer without specifying a viewMode prop,
it automatically determines the appropriate ViewMode based on the current
window width:
- Desktop: Width > 900px
- Tablet: 600px < Width ≤ 900px
- Mobile: Width ≤ 600px
Live example
Here’s a simple form that demonstrates automatic view mode detection. Try resizing your browser window to see how the form adapts:live
Manual View Mode Control
While automatic detection works well for most use cases, you might need to manually control the view mode for testing, demonstration, or specific user requirements. You can do this by passing the viewMode prop toFormViewer. The prop accepts
a ViewMode value:
Live example with view mode selector
This example shows how to manually control the view mode using a selector. Try switching between different view modes to see how the form adapts:live
Device-Specific Styling
The real power of adaptive layouts comes from device-specific styling. FormEngine Core allows you to define different styles for each view mode using thecss and wrapperCss properties with any, desktop, tablet, and mobile keys.
CSS Property Structure
Understanding Style Cascading
Styles cascade from general to specific:anystyles apply to all devices- Device-specific styles (
desktop,tablet,mobile) override or extendanystyles - Inline string styles in the
stringproperty override object styles
Complete Adaptive Form Example
Here’s a comprehensive example that demonstrates adaptive layout techniques for a user registration form:live
Common Issues and Solutions
Form Doesn’t Adapt When Resizing
- Cause: Custom
viewModeprop overrides automatic detection - Solution: Remove the
viewModeprop or implement your own resize handling
Styles Not Applying Correctly
- Cause: Incorrect style cascading or missing
anyblock - Solution: Ensure
anystyles exist and device-specific styles override correctly
Layout Shifts on Mobile
- Cause: Different font sizes or image dimensions
- Solution: Use relative units (rem, sv*, cq*) and set explicit dimensions for media
Summary
FormEngine Core’s adaptive layout system provides:- Automatic view mode detection based on screen width
- Manual control via the
viewModeprop when needed - Device-specific styling through
cssandwrapperCssproperties - Responsive design patterns that work across all devices
For more information:
- Styling Components and Forms
- Component Library
- FormViewer API Reference
Next steps
- Styling — Apply CSS and design customizations to your forms
- Embedded Forms — Create responsive nested forms