Overview
Cells are lightweight renderers used primarily for rendering individual columns in tables or items in arrays. They are simpler than full controls and don’t include labels or error messages.Cell vs Control
Controls are full-featured form elements with:- Labels
- Error messages
- Descriptions
- Full layout support
- Just the input element
- No built-in label or error display
- Used in tables and compact layouts
- Better performance for large datasets
Cell Props
Cells receive the following props:Creating a Custom Cell
Example: Simple Text Cell
Example: Material UI Text Cell
From the JSON Forms Material renderers:Common Cell Types
Boolean Cell
Number Cell
Integer Cell
Enum Cell
Date Cell
Registering Custom Cells
Register cells separately from renderers:Using the withJsonFormsCellProps HOC
ThewithJsonFormsCellProps Higher-Order Component connects your cell to the JSON Forms state:
- Automatic data binding
- Path resolution
- State management
- Visibility and enablement handling
Cells in Table Arrays
Cells are automatically used when rendering table arrays:Cell Registry
JSON Forms uses a cell registry similar to the renderer registry:Best Practices
- Keep cells simple: Cells should be lightweight and focused on rendering the value
- No labels or errors: Cells shouldn’t render labels or error messages
- Handle undefined data: Always check for
undefinedornulldata - Use proper types: Ensure type conversions are correct (e.g.,
parseIntfor integers) - Respect enabled prop: Disable the input when
enabledisfalse - Apply className: Pass through the
classNameprop for styling - Use unique ids: Apply the
idprop for accessibility - Performance matters: Keep cells performant as they’re used in large lists