Wizard with progress and review
What it combines
FormConfig.stepsUi— a progress bar, dots, numbered steps or a sidebar, drawn by<Form />(Multi-Step Forms)stepsUiPlugin()from@saastro/forms/steps— without itstepsUidraws nothing- A review step —
Step.review(StepBuilder#review()), a step with no fields that summarises the previous ones goToStep— what each Edit button on the review uses to return to its step
Fill two steps, then read the review: each block has an Edit button that returns to that step, and the bar lets you jump back to a step you have already visited. The send button only shows the values.
Fill the steps, check the review, then send…
import { FormBuilder, PluginManager } from '@saastro/forms';
import { stepsUiPlugin } from '@saastro/forms/steps';
/**
* Three steps, a progress bar and a final review. The bar comes from `stepsUi` (it needs
* `stepsUiPlugin()` registered); the review is a step flagged `review`, which draws the earlier
* answers by step, each with an Edit button that goes back to that step with `goToStep`.
*/
export function createConfig() {
const plugins = new PluginManager();
plugins.register(stepsUiPlugin());
const config = FormBuilder.create('wizard-review')
.layout('manual')
.columns(12)
.addField('name', (f) => f.type('text').label('Full name').required().columns({ default: 12 }))
.addField('email', (f) =>
f.type('email').label('Email').required().email().columns({ default: 12 }),
)
.addField('plan', (f) =>
f
.type('radio')
.label('Plan')
.required()
.options([
{ value: 'starter', label: 'Starter' },
{ value: 'team', label: 'Team' },
])
.columns({ default: 12 }),
)
.addField('notes', (f) =>
f.type('textarea').label('Anything else?').optional().rows(3).columns({ default: 12 }),
)
.step('about', 'About you', (s) => s.fields('name', 'email').defaultNext('plan'))
.step('plan', 'Your plan', (s) => s.fields('plan', 'notes').defaultNext('review'))
// Last step, no fields of its own: it summarises the ones before it.
.step('review', 'Review', (s) => s.fields().review())
.initialStep('about')
.usePlugins(plugins)
.build();
return {
...config,
// `navigable` lets the visitor go back to steps already visited from the bar itself.
stepsUi: { mode: 'progress' as const, variant: 'steps' as const, navigable: true },
};
}The code
The Code tab above is the whole form. The two pieces that matter are the plugin plus stepsUi, and the last step:
plugins.register(stepsUiPlugin());
.step('review', 'Review', (s) => s.fields().review())
// after build():
{ ...config, stepsUi: { mode: 'progress', variant: 'steps', navigable: true } }
How it works
- The review is just a step — put it last, usually with
fields: []. It prints one block per step on the visitor’s real path, computed from the current values. - Edit returns to that step with
goToStep; the review is recomputed from the current values when the visitor comes back. navigablelets the visitor jump to a step already visited (the same asFormRef.goToStep).stepsUiis configuration, not builder: the builder has no method for it, so spread it onto the built config (or write it in the JSON config).
Caveats
- Register the plugin —
stepsUiwithoutstepsUiPlugin()draws nothing and logs one warning per form.<Form />never imports/steps, so forms without a progress bar do not pay for it. - Empty answers are not listed, and a block with nothing says so. Hidden fields and resolvers, the consent checkbox, files and signatures are left out, by the same rule as the WhatsApp summary.
- Conditional routing still applies — after an edit, a branch that no longer applies loses its block, because the review follows the path and not the history.
- Texts follow the form’s locale (
en/esbuilt in); override them withsetDefaultMessages.
Variations
variant: 'bar'or'dots'for a lighter indicator;mode: 'sidebar'for a vertical menu.mode: 'none'and your own component through a plugin’sstepsUiif you need a different look.