Build an accessible React form without state traps
8 steps · about 4 h 30 min · Intermediate
- Choose the owner of form state (guide, React documentation, 35 min)
Lift only the state that multiple fields or summary components genuinely need to coordinate.
- Control text inputs deliberately (reference, React documentation, 40 min)
Keep value and change handling consistent while avoiding accidental switches between controlled and uncontrolled modes.
- Model selections explicitly (reference, React documentation, 30 min)
Bind single and multiple choices to state without relying on selected attributes in option markup.
- Handle longer text safely (reference, React documentation, 25 min)
Use value or defaultValue consistently and preserve user input across validation attempts.
- Define submission behaviour (reference, React documentation, 35 min)
Coordinate native form semantics, pending work and success or failure without attaching logic to each button.
- Give every control a usable label (guide, W3C Web Accessibility Initiative, 30 min)
Connect visible instructions and programmatic names so pointer, keyboard and assistive-technology users share the same form.
- Announce validation feedback (guide, W3C Web Accessibility Initiative, 35 min)
Associate errors with fields, summarise them and move attention appropriately after a failed submission.
- Make complex updates predictable (guide, React documentation, 40 min)
Centralise transitions when many fields and submission states make scattered setters hard to audit.