- Docs
- Forms
Forms
How to build accessible forms with Kanpeki.
Architecture
Kanpeki's form system is built on three layers:
Field (Layout)
Field is the composition and layout root. It owns:
- Label placement and styling
- Description text
- Error message rendering
- Visual structure and orientation
TextField (Behavior)
TextField is a React Aria component that provides:
- Automatic ID wiring (label, description, error)
- Validation state
- Keyboard and focus handling
- ARIA attributes
TextField is composed into Field using the render prop:
Form (Coordination)
Form is a minimal wrapper that handles:
- Submission via
onSubmit - Server-side validation errors
- Reset handling
Form does not manage fields or control layout.
Composition Pattern
The recommended pattern composes TextField into Field:
Without TextField
You can use Field with Input directly, but you lose React Aria's automatic ID wiring:
This requires manual htmlFor, id, and aria-describedby attributes.
Libraries
Choose a form library based on your needs: