Sub topic 9
Navigation, Back Button, and Progress Indicators
Assume you know basic HTML form controls, TypeScript or JavaScript, and browser form submission. Also assume the form already has explicit step state, such as account, details, and review.
Navigation controls should answer three questions:
- Where am I?
- What can I do next?
- Can I return without losing my work?
Designing step navigation
Keep navigation consistent across steps. A typical flow has:
- A primary action, such as Continue or Review order.
- A secondary Back action on every step except the first.
- A final Submit action on the review step.
- A link to leave the flow only when leaving is safe and understandable.
The Continue action should validate the current step before changing the step. The Back action should normally preserve values and avoid blocking the user because of errors on the current step. A user may need to go back to check an earlier answer even when the current step is incomplete.
const steps = ["account", "details", "review"] as const;
type StepId = (typeof steps)[number];
type State = {
step: StepId;
values: Record<string, string>;
errors: Record<string, string>;
};
function moveBack(state: State): State {
const index = steps.indexOf(state.step);
return {
...state,
step: steps[Math.max(index - 1, 0)],
errors: {},
};
}
function moveForward(
state: State,
validate: (step: StepId, values: Record<string, string>) => Record<string, string>,
): State {
const errors = validate(state.step, state.values);
if (Object.keys(errors).length > 0) {
return { ...state, errors };
}
const index = steps.indexOf(state.step);
return {
...state,
step: steps[Math.min(index + 1, steps.length - 1)],
errors: {},
};
}The reducer keeps values separate from the current step. Moving back changes only step and errors, so entered values remain available.
Progress indicators
A progress indicator gives orientation, but it should not create false expectations. Use numbered steps when the flow has a stable sequence:
| Step | Label | Status example |
|---|---|---|
| 1 | Account | Complete |
| 2 | Details | Current |
| 3 | Review | Not started |
Show labels that describe the user's task, such as Delivery details, rather than internal names such as step-2. If the number of steps can change because of conditional fields, use a broader message such as “Step 2 of 4” only when that count is stable.
A progress indicator can be:
- Non-interactive, showing status only.
- Interactive, allowing the user to revisit completed steps.
- Partly interactive, allowing completed steps but not future steps.
If users can select a completed step, the destination must restore its values and validation state. Do not let a progress link bypass required validation rules for submission.
Browser history and accessibility
Decide whether each step should have its own URL. Separate URLs make browser Back, refresh, bookmarks, and analytics easier to reason about. If a step is represented in the URL, update it with the History API without causing a full page reload. On browser Back, restore the matching step from state or a saved draft.
When a step changes:
- Move focus to the new step heading or the first invalid field.
- Announce the new step and its position to screen readers.
- Give the Back and Continue buttons clear accessible names.
- Keep keyboard focus within normal document order.
- Do not disable Back merely because the current step has errors.
Exercise
A user enters a name on step 2, clicks Back, changes an answer on step 1, and returns to step 2. What should happen to the name?
Show answer
The name should still be present because navigation changes the current step without clearing shared form values.