Build an accessible React form without state traps

8 steps · about 4 h 30 min · Intermediate

  1. 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.

  2. Control text inputs deliberately (reference, React documentation, 40 min)

    Keep value and change handling consistent while avoiding accidental switches between controlled and uncontrolled modes.

  3. Model selections explicitly (reference, React documentation, 30 min)

    Bind single and multiple choices to state without relying on selected attributes in option markup.

  4. Handle longer text safely (reference, React documentation, 25 min)

    Use value or defaultValue consistently and preserve user input across validation attempts.

  5. Define submission behaviour (reference, React documentation, 35 min)

    Coordinate native form semantics, pending work and success or failure without attaching logic to each button.

  6. 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.

  7. Announce validation feedback (guide, W3C Web Accessibility Initiative, 35 min)

    Associate errors with fields, summarise them and move attention appropriately after a failed submission.

  8. Make complex updates predictable (guide, React documentation, 40 min)

    Centralise transitions when many fields and submission states make scattered setters hard to audit.