What Are Container Components?
Container components are React components that:- ✅ Can contain child components
- ✅ Provide layout structure
- ✅ Support flexible styling
- ✅ Manage nested component relationships
- ❌ Typically don’t have interactive form data (but can have other props)
- Layout wrappers (Grid, Flex containers)
- Cards with dynamic content
- Tabs and accordions
- Modal dialogs
- Form sections and groups
- Custom layout structures
Basic Container Component Structure
Every container component follows this pattern:- Use
.kind('container')to mark it as a container - Accept
childrenprop in the React component
Defining Container Kind
The.kind('container') method is essential for container components:
'container'- Can contain child components'component'- Regular component (default)
The Children Property
Container components use thenode annotation for the children property:
Rendering Differences
The key difference between container components and regular components lies in how FormEngine Core wraps them during rendering.How FormEngine Core Renders Components
FormEngine Core uses a rendering pipeline that adds functionality through wrapper components. Here’s what happens internally: For regular components (kind: ‘component’):Regular Component Wrappers
When a regular component renders, it receives three wrapper layers:- Tooltip Wrapper - Adds tooltip functionality if the component has
tooltipPropsconfigured - Default Wrapper - Provides consistent styling, layout, and component isolation
- Error Wrapper - Handles validation errors, displays error messages, and manages error states
Container Component Rendering
Container components render directly without any wrappers:Why This Design Makes Sense
Containers are structural elements:- They organize layout and group other components
- They don’t typically hold form data that needs validation
- They don’t need tooltips (users don’t hover over layout sections)
- They benefit from cleaner DOM output for CSS styling
- They need validation error display
- They benefit from tooltips for user guidance
- They require consistent styling through wrappers
- They often have form data that needs error handling
When to Choose Container vs Regular Components
Use kind: ‘container’ when:- Creating layout structures (grids, flex containers, cards)
- Grouping related form fields visually
- Building complex nested component hierarchies
- You don’t need validation or tooltips for the container itself
- Creating form fields (inputs, selects, checkboxes)
- Building interactive controls that need validation
- Components should display tooltips for user guidance
- You need consistent styling through the wrapper system
Performance Considerations
Container components render faster because:- Fewer React components in the tree
- Less wrapper prop passing and context consumption
- Cleaner DOM output for browser rendering
- No unnecessary error or tooltip logic execution
Real-World Examples
Example 1: Flex Layout Container
Live Example
live
Example 2: Card Container with Header
Live Example
live
Best Practices
1. Always Accept className and style Props
2. Define Sensible Defaults for CSS Properties
3. Use Appropriate Property Types
- Use
nodefor children - Use
sizefor dimensions (padding, margin, etc.) - Use
colorfor color values - Use
oneOffor enumerated values (flexDirection, etc.)
4. Document Your Container’s Purpose
Summary
Container components are powerful building blocks in FormEngine Core that enable complex layouts and nested component structures. Key takeaways:- Use
.kind('container')to mark a component as a container - Include a
childrenproperty with thenodeannotation - Design components to accept both
classNameandstyleprops - Define CSS properties using the
.css()method - Configure styles through the
cssproperty in form JSON