Step Dialog
A multi-step form on one schema, in a Dialog or inline: a progress list with aria-current, Next validates only the current step, Back keeps values, focus moves to each step's heading, and a failed submit returns to the step with the error.
Example
step-dialog-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
Use StepDialog (or StepForm inline) when one schema is too long for one screen.
API reference
StepFormFrame
| Prop | Type | Default |
|---|---|---|
stepsrequired | readonly FormStep<FormValuesOf<Schema>>[] | – |
stepThe current step's id, controlled. | string | – |
defaultStep | string | – |
onStepChange | (step: string, details: StepChangeDetails) => void | – |
labelsButton and progress labels in the page's language; English by default. | StepFormLabels | – |
pendingLabelWhat screen readers hear once a submit or a step's `validate` has been pending for a second. | string | – |
headingLevel | 2 | 3 | 4 | 2 |
rootErrorTitle | ReactNode | – |
cancel | ReactNode | – |
onCancel | () => void | – |
body | ComponentType<{ children?: ReactNode }> | DefaultBody |
actionsClassName | string | – |
Also takes FormProps except children.
StepForm
| Prop | Type | Default |
|---|---|---|
stepsrequired | readonly FormStep<FormValuesOf<Schema>>[] | – |
stepThe current step's id, controlled. | string | – |
defaultStep | string | – |
onStepChange | (step: string, details: StepChangeDetails) => void | – |
labelsButton and progress labels in the page's language; English by default. | StepFormLabels | – |
pendingLabelWhat screen readers hear once a submit or a step's `validate` has been pending for a second. | string | – |
headingLevel | 2 | 3 | 4 | – |
rootErrorTitle | ReactNode | – |
Also takes FormProps except children.
StepFormProgress
| Prop | Type | Default |
|---|---|---|
stepsrequired | readonly { id: string; title: ReactNode }[] | – |
currentrequired | number | – |
labelrequiredNames the list for screen readers, in the page's language. | string | – |
className | string | – |
StepDialog
Takes StepDialogProps<Schema, Result>.
Other exports
useHeadingFocususeSeenFieldsuseSubmitInterceptoruseFocusFirstStepOnRestarttype FormSteptype StepChangeDetailstype StepDirectiontype StepFormLabelstype StepFormPropstype StepFormProgressPropstype StepDialogLabelstype StepDialogOpenChangeDetailstype StepDialogOpenChangeReasontype StepDialogPropstype StepDialogResultActionstype StepDialogResultStepAccessibility
- The progress is an ordered list; the current step has aria-current="step".
- Next and Back move focus to the step's heading; a failed submit returns to the step with the first error and focuses it.
- Enter on any step goes to the next one, and on the last step submits.
Agent actions
Agents fill each step's fields by label and press Next, Back and the submit button by name.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.