Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Blocks
  2. Form Wizard
  3. Usage

Form wizard

Usage

Overview
FormWizard from @prepared911/ui/blocks/form-wizard is the full-viewport wizard for a multi-step create flow. It composes TakeoverDialog, Stepper and FormLayoutStandard: a stepper, the current step's form in a column of at most 640px, a pinned footer, and a header. You pass the steps, the current step id, the copy and the current step's fields. You own the values, the validation and any discard prompt.
When to use
  • A create flow with several steps. New agency, new user, new rule: each step is one form, and later steps depend on earlier ones.
  • A flow a person can leave and resume. Pass onSaveAndExit when there is something to save.
When not to use
  • One form. Use FormDialog or FormLayoutDrawer.
  • One task with no steps. Use TakeoverDialog.
  • Progress without a form. Use Stepper on its own.
Layout
  • Header. The flow's name (title), then Save & exit as a ghost button when you pass onSaveAndExit, then the close control at the inline end. The close control is Cancel. At narrow widths Save & exit wraps to a second row while the close control stays on the title row.
  • Footer. Full width and pinned. Back (secondary, absent on the first step) then Continue, the only primary, together at the inline end of the form column. On the last step Continue takes submitLabel, the finishing verb of the flow, such as "Create agency". There is no step counter, no Cancel and no Save & exit in the footer.
  • Form. The current step's name, its description and its fields, in a column of at most 640px. Only this region scrolls.
  • Stepper. A vertical rail for up to 7 steps. More than 7 steps, sections, stepperLayout={FormWizardStepperLayout.Top}, or a container narrower than 640px puts a horizontal stepper above the form, pinned while the form scrolls.
Steps and validation
Continue submits the current step's form and calls onStepSubmit({ stepId, nextId, isLast, event }). Read the fields with new FormData(event.currentTarget) and validate there. Continue is never disabled for an invalid or pristine form.
  • Valid. Set current to nextId, or finish the flow when isLast. Focus moves to the new step's title, the stepper announces the change and the form scrolls to its top.
  • Invalid. Keep current, mark the fields invalid and pass stepErrors. Focus moves to the first invalid field. The footer shows no error summary. Clear the entry when the step is valid again.
  • Back and step selection. onCurrentChange runs with no validation. By default only completed steps are reachable.
  • Pending. Pass pending, or return a promise from onStepSubmit. The primary shows submitPendingLabel; Back and the stepper are unavailable.
Discarding
The wizard tracks no unsaved edits. When the close control (or Escape) asks to close, onOpenChange(false, details) runs; call details.cancel() and show your own prompt with "Keep editing" and "Discard".
Header and footer wording
The control that opens the flow says "New …". The last step's primary is the footer's submit, so "Create agency" or "Save agency" is right. Save & exit is always "Save & exit", never plain "Save".
Previous
Call Transcript / Accessibility
Next
Form wizard / API and Development
On this page
Overview
When to use
When not to use
Layout
Steps and validation
Discarding
Header and footer wording