To disable a stepper when the page is invalid in React, you keep the current step's validity in state, pass a disabled prop to the stepper's forward/next control (and the step buttons), and derive that boolean from the same validator the submit handler uses. The stepper should call onStepChange only when the guard passes; the guard reads isValid, so users cannot advance past an invalid page. The key condition: validation must be synchronous and deterministic at the moment of the click, or the button can briefly enable on stale state.
The rest of this article builds that pattern properly. It covers why naive disabled={errors.length > 0} breaks, how to lift validity out of component-local form state, how to handle multi-field pages, async validation, and the accessibility and UX costs of disabling rather than blocking.
Why the Obvious Approach Fails
Most invalid-stepper bugs come from three related mistakes. First, validity lives inside the step component's local form state, so the stepper shell—the component that actually renders the buttons—has no idea whether the page is valid. Second, the disabled attribute is computed from a value that updates one render after the user's keystroke, so the button state lags reality. Third, the guard is duplicated: the button checks errors.length, the submit handler checks form.isValid, and the two disagree because they run at different times or use different rules.
React's controlled form model makes this visible. If you validate on every change and store the result in state, the button re-renders with the correct disabled value on the next commit. If you validate only on blur or on submit, the button can stay enabled while the field is visibly empty. And if validation is asynchronous, there is always a window where the page is invalid but the button is still enabled because the pending promise hasn't resolved.
A second failure mode is subtler: disabled buttons don't fire click events, so any "explain why you can't continue" affordance attached to the button stops working. Users on a long form often can't tell which field blocks progress. That's why you usually want the button rendered but non-advancing, or disabled together with inline error messages that appear on blur.
Prerequisites
Before wiring the stepper, confirm four things:
1: A single validator per step. One function (or one schema, if you use a library like Zod, Yup, or React Hook Form's resolver) returns a boolean or an error map for the current step's fields. The stepper, the submit handler, and the next-button guard must all call this same function. 2: Step-owned field state lifted to the wizard. Either a single form object in the wizard parent, or a per-step state slice the parent can read. Validity cannot be trapped inside the step component if the parent renders the buttons. 3: A stable notion of "current step." An index in state, not derived from the URL alone, unless the URL is the source of truth and you hydrate from it. 4: A decision about disable vs. block. Disabling is simpler; blocking with an error message is friendlier. This article covers both, but the pattern is the same: compute a canAdvance boolean and use it to control the step transition.
Step-by-Step: The Core Pattern
1: Define the validator as a pure function
Put the rule in one place. For a page with name and email:
A pure function is testable without a DOM and cannot disagree with itself between renders.
2: Lift step values into the wizard parent
Now the stepper shell—the component that renders the buttons—can validate.
3: Derive canAdvance in the stepper shell
Two details matter here. The goNext guard is not redundant with disabled: it protects against programmatic calls, Enter-key submission in some setups, and the moment when a stale render still has the old attribute. And aria-disabled does nothing on a native disabled button, but it becomes meaningful if you switch to a blocked-but-clickable button later.
4: Check success
Click Next with an empty required field. The button should not advance the step. Fill the field; with validation on change, the button should enable before the next keystroke after the value commits. Confirm with React DevTools that Stepper re-renders after setValues—if it doesn't, the value isn't actually lifted.
Step Buttons: Disabling Forward Jumps Only
A stepper usually renders one button per step. You rarely want to disable back buttons, and you usually want to disable forward jumps past the first invalid page. Compute reachability:
Render step buttons with disabled={!canJumpTo(index)}. This lets users back out of step 3 to step 1 without revalidation, but stops them jumping from step 1 to step 4 while step 2 is incomplete. The check runs on every render, so it's O(steps) per keystroke—fine for typical 3–6 step wizards, worth memoizing if your validator is expensive.
One trap: don't disable the current step button. Users understand clicking the step they're on as a no-op or a reset. Disabling it looks broken.
Multi-Field Pages and Per-Field Errors
Disabling the whole Next button is blunt when a page has five fields. The friendlier pattern: keep Next enabled, but on click, run validation, set a showErrors flag, and focus the first invalid field. The step doesn't advance, errors appear, and the user knows what to fix.
If you keep disabled, pair it with validation on blur so errors surface as users leave fields, not only after they fill everything. A disabled button with no visible errors is the worst combination: the user sees a dead control and no reason.
Async Validation Without Flicker
Async checks—username availability, server-side eligibility—create a race. The clean approach is a tri-state: idle, checking, valid. Disable Next while checking, and cancel stale requests with an AbortController or a request-id token.
Debounce the check (300–500 ms after typing stops), and show a spinner in the button or adjacent text so the disabled state reads as "wait" rather than "blocked." Never let a slow response for an old value land after a newer one—tag each response with the request sequence number and ignore out-of-order results.
Accessibility and UX Costs of Disabling
Disabled buttons are invisible to keyboard focus, have no hover feedback, and give screen-reader users no explanation. WCAG guidance favors keeping controls operable when possible. Two mitigations:
aria-disabled="true" with a click handler that no-ops and announces why, e.g., aria-describedby pointing to a live region saying "Add an email to continue." The button stays focusable and explainable. Keep disabled but render persistent helper text under the button describing the unmet requirement. Simpler, less code, still accessible if the text is adjacent and associated.
Either way, avoid disabled on a button whose label doesn't change, because sighted users may not connect the dead control to the empty field three inputs up.
Where to Stop and Hand Off
These checks cover almost all wizard steppers. Stop and involve a colleague or framework specialist when: you're wiring validity across a form library and a custom stepper you didn't write (check that the resolver's mode prop matches your blur/change expectation); the wizard persists across page reloads and must rehydrate validity from a server draft; or you're using a headless stepper from a component library whose disabled prop means something different from a native attribute. If the form handles payment, health, or legal consent, also confirm the blocked-vs-disabled choice with whoever owns compliance—silently disabling a continue button on a regulated flow can be a finding.
FAQ
Can I just put the entire step component inside fieldset disabled?
A disables every form control inside it, which blocks the fields themselves—not what you want. It's useful during submission, not for gating navigation.
Why does the Next button enable before I finish typing?
Validation on change runs on committed values; some setups commit on blur, and libraries like React Hook Form default to mode: "onSubmit". Set mode: "onChange" or reValidateMode: "onChange" so validity tracks keystrokes.
My Next button flashes enabled after clearing a required field. What's wrong?
You're probably reading errors from a ref or from a stale closure. Make sure the disabled value is computed from state in the render that renders the button.
Should the stepper block going backward?
Almost never. Backward navigation should preserve values and not re-run forward validation, so users can fix earlier pages without being trapped.