Accessible mutation feedback
What you need to know
Accessible mutation feedback tells users what happened without relying on color, mouse interaction or the ability to see a spinner. A failed submission should leave the user able to repair the input.
By the end, you can: announce errors and success; preserve input and focus.
Associate an error with the input
// Client Component fragment; render with actual action result'use client';export function TitleField({value,error,onChange}: { value:string; error:string; onChange:(s:string)=>void;}) { return <div> <label htmlFor="book-title">Book title</label> <input id="book-title" name="title" value={value} onChange={e=>onChange(e.target.value)} aria-invalid={Boolean(error)} aria-describedby="title-error" /> <p id="title-error">{error}</p> </div>;}Expected behavior: The label and error are associated with the input; its value is controlled by the parent.
How it works
A label gives the field an accessible name; aria-describedby associates explanatory text with the field, and aria-invalid communicates validation failure. Keep a live status region mounted before its text changes so assistive technology can announce results. Use an alert for important errors when appropriate; do not make every message assertive. A controlled input lets you keep the entered value when an action returns a validation error, instead of relying on automatic form reset behavior. A validation error returned as data is still a normally resolved action, so uncontrolled inputs may reset even though the business operation was rejected. On confirmed success, reset only when the workflow calls for it. If several fields fail, offer a summary and move focus deliberately to the summary or first invalid field when that helps; avoid moving focus on every keystroke. A disabled control cannot be used to retry until the operation completes. Check keyboard navigation and real screen reader announcements separately from static markup review.
Keep feedback visible across outcomes
export function Feedback({pending,error,saved}: { pending:boolean; error:string; saved:boolean;}) { return <div> <p role="status">{pending ? 'Saving…' : saved ? 'Saved' : ''}</p> <p role="alert">{error}</p> </div>;}Expected behavior: The status and alert elements persist; their content changes when the mutation state changes. Actual announcement timing needs assistive-technology testing.
Common mistake
Do not show a red border with no textual explanation or replace a form with a success screen on failure. Preserve data on error and distinguish pending from confirmed success.
Practice and verification
With keyboard only, submit an invalid title and correct it. Specify the expected focused element, visible error, retained value and retry result. In a browser test inspect accessible names and use a real screen reader for announcement checks.
Scope: App Router, proposed Next.js 16.x, React 19 family, Cache Components disabled. Framework snippets are static or explicitly partial; actual browser, auth and generated-route checks are pending. SQLite exercises run separately in the authoring environment, not the ByteMind evaluator.
Further reading: Forms · Form Status · A11Y