Skip to content
Eskais UI

Forms

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

Installation

npx shadcn@latest add @eskais/step-dialog
npm packages@standard-schema/spec@1.1.0react-hook-form@7.91.0class-variance-authority@0.7.1lucide-react

Usage

Import
import { StepForm, StepFormFrame } from "@/components/ui/step-form"import { StepFormProgress } from "@/components/ui/step-form-progress"import { StepDialog, StepForm } from "@/components/ui/step-dialog"import { useHeadingFocus, useSeenFields, useSubmitInterceptor } from "@/components/ui/use-step-form"import { useFocusFirstStepOnRestart } from "@/components/ui/use-step-dialog-focus"

Use StepDialog (or StepForm inline) when one schema is too long for one screen.

API reference

StepFormFrame

PropTypeDefault
stepsrequiredreadonly FormStep<FormValuesOf<Schema>>[]–
stepThe current step's id, controlled.string–
defaultStepstring–
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–
headingLevel2 | 3 | 42
rootErrorTitleReactNode–
cancelReactNode–
onCancel() => void–
bodyComponentType<{ children?: ReactNode }>DefaultBody
actionsClassNamestring–

Also takes FormProps except children.

StepForm

PropTypeDefault
stepsrequiredreadonly FormStep<FormValuesOf<Schema>>[]–
stepThe current step's id, controlled.string–
defaultStepstring–
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–
headingLevel2 | 3 | 4–
rootErrorTitleReactNode–

Also takes FormProps except children.

StepFormProgress

PropTypeDefault
stepsrequiredreadonly { id: string; title: ReactNode }[]–
currentrequirednumber–
labelrequiredNames the list for screen readers, in the page's language.string–
classNamestring–

StepDialog

Takes StepDialogProps<Schema, Result>.

Other exports

useHeadingFocususeSeenFieldsuseSubmitInterceptoruseFocusFirstStepOnRestarttype FormSteptype StepChangeDetailstype StepDirectiontype StepFormLabelstype StepFormPropstype StepFormProgressPropstype StepDialogLabelstype StepDialogOpenChangeDetailstype StepDialogOpenChangeReasontype StepDialogPropstype StepDialogResultActionstype StepDialogResultStep

Accessibility

  • 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.