Web · Components
Stepper
Step indicator showing which step of a task you are on (progress chart).
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Server action: jumps to the step of the field that returned an error by itself
Preview
Code
Events
- Events appear here when you interact with the preview.
Vertical: the content of the selected step opens below it
Bar and dot styles, name below
Import
Step indicator showing which step of a task you are on (progress chart). Steps are given with the items array. For a full flow with forms, validation and buttons use Wizard; Stepper is only the indicator.
- States are computed from the order (previous ones ✓); to show an error, warning, loading or skipped, pass
statusto the step. - If
onValueChangeis given, completed steps can be clicked to go back (all of them withnavigation="all"). Tab and Enter/Space work on the keyboard. - Accessibility: an ordered list inside
<nav>; the selected step hasaria-current="step", states are read to screen readers. - Mobile: Horizontal steps switch to a summary view on narrow screens (below 640 px): "Step 2 / 5", the name itself, the next step and a segmented bar. Done with CSS only; renders correctly on the server too, without shift. With
mobile="scroll"the full list scrolls sideways. - In the vertical view the selected step's
contentopens below its name. - In right-to-left (RTL) writing the lines and order flip automatically.
Examples
Step-by-step form (wizard): step indicator, step fields, Back / Next / Complete buttons and per-step validation in one component. Steps are given with the steps array; use ready-made fields like TextField, SelectField as content.
How it works:
- All steps are inside a single
Form; hidden steps stay in the DOM. So input isn't lost when going back, and on the last step all fields are submitted as a singleFormData(server action included). - Pressing Next validates only that step's fields with browser rules; errors are shown below the fields and the first invalid field is focused. Then the step's
validatefunction (can be async) runs, if any. - The Enter key moves to the next step, and submits on the last step.
- If the server action returns
state.errors, it automatically goes to the step containing the invalid field and focuses it. - Invalid steps are red (!) in the indicator, passed ones ✓, skipped ones dashed. Visited steps can be revisited by clicking the indicator.
Mobile and accessibility:
- On narrow screens the indicator switches to the "Step 2 / 5" summary.
- The back button (phone/browser) returns to the previous step (
backButton). - When the step changes the new step's title is focused (read by the screen reader), and if the top of the wizard is above the screen it is scrolled into view.
- With
stickyFooterthe buttons stick to the bottom of the screen. - The step transition slides in by direction; off with the reduced motion preference.
Examples
resolveStepStatus
functionComputes the step's state from the order and the manually given state.
useWizard
functionReturns the state and navigation functions of the nearest Wizard. For writing your own buttons or showing a summary in step content.
Examples
StepStatus
typeState of a step.
complete: completed (✓).current: the current step.upcoming: not reached yet.error: invalid; needs fixing (!).warning: has a warning but you can proceed (!).loading: an operation is running in the step (spinner).skipped: an optional step was skipped (dashed).
StepItem
interfaceA step inside Stepper.
| Name | Type | Description |
|---|---|---|
label | ReactNode | Name of the step. |
description? | ReactNode | Short description below the name. |
icon? | IconProp | Icon shown instead of the number: name or element. Replaced by ✓ when completed. |
status? | StepStatus | State of the step. If omitted, computed from the order: previous ones complete, the selected one current, later ones upcoming. Pass it to show an error or loading. |
optional? | boolean | ReactNode | Optional step: "İsteğe bağlı" is written below the name. If text is given, that is written. |
disabled? | boolean | Not clickable and looks faded. |
content? | ReactNode | Content shown below the step name in the vertical view while the step is selected (e.g. that step's form and buttons). Not used in the horizontal view. |
tooltip? | TooltipProp | Tooltip shown when hovering the step. See TooltipProp. |
StepperVariant
typeStyle of the step indicator.
circle: numbered circles with filling lines between them.dot: small dots; for simple flows.bar: a bar for each step with its name below (checkout page style).
StepperMobile
typeView of horizontal steps on narrow screens (below 640 px).
compact: "Step 2 / 5", the step's name, the next step and a segmented progress bar. Always fits the screen.scroll: the full list scrolls sideways; the selected step is brought into view.full: unchanged (if steps are few and names are short).
StepperClassNames
interfaceClasses that can be passed to the inner parts of Stepper.
| Name | Type | Description |
|---|---|---|
list? | string | Step list (<ol>). |
step? | string | Each step (<li>). |
indicator? | string | Circle, dot or bar. |
connector? | string | Line between steps. |
label? | string | Step name. |
description? | string | Step description. |
content? | string | Step content in the vertical view. |
compact? | string | Summary view on narrow screens. |
StepperProps
interfaceProps of the Stepper component.
Extends: Omit<ComponentProps<"nav">, "defaultValue" | "onChange" | "children">
| Name | Type | Default | Description |
|---|---|---|---|
items | readonly StepItem[] | Steps. | |
value? | number | Index of the selected step in controlled use (starts at 0). | |
defaultValue? | number | 0 | Initial step in uncontrolled use. |
onValueChange? | (index: number) => void | Called when a step is clicked. | |
navigation? | StepperNavigation | "completed"` if `onValueChange` is given, otherwise `"none" | Which steps can be clicked. See StepperNavigation. |
orientation? | "horizontal" | "vertical" | "horizontal" | Layout. |
variant? | StepperVariant | CustomVariant<"stepper"> | "circle" | Indicator style: built-in, or a custom one added with defineAppearance (its classes are added to the root; drawn like circle unless extends is given). If omitted, UIProvider appearance.defaults.stepper.variant. See StepperVariant. |
effect? | EffectProp | Effect or effects of the step indicators (circle, dot, bar) (e.g. "pulse", ["lift", "glow"]). The accent color is the primary color. If omitted, UIProvider appearance.defaults.stepper.effect. See BuiltinEffect. | |
labelPlacement? | "end" | "bottom" | "end" | Position of the name in the horizontal view: next to the circle (end) or below it (bottom, steps are equal width). |
mobile? | StepperMobile | "compact" | View on narrow screens. See StepperMobile. |
size? | Size | "md" | Size. |
label? | string | "Adımlar" | Screen reader name. |
classNames? | StepperClassNames | Classes added to the inner parts. |
Return value of a step's validate function.
undefined/true: valid, it advances.false: doesn't advance (if you showed the message yourself).- Text: shown in an error box above the step.
{ fieldName: "message" }: messages are shown below fields with a matching name (like a server error); they clear when the user changes the value. Messages for names not in the step fall into the error box.
WizardContextValue
interfaceValue received by useWizard and step content given as a function.
| Name | Type | Description |
|---|---|---|
step | number | Index of the current step (starts at 0). |
count | number | Number of steps. |
isFirst | boolean | Is it on the first step? |
isLast | boolean | Is it on the last step? |
busy | boolean | Is a validation or submission running? |
next | () => Promise<boolean> | Validates the step and moves to the next one. Returns true if it moved; otherwise focuses the invalid field and returns false. |
back | () => void | Returns to the previous step (no validation). |
goTo | (index: number) => Promise<boolean> | Goes to a step. When going forward (in a linear flow) the steps in between are validated; it stops at a step that doesn't pass. |
skip | () => void | Skips an optional step without validating; its fields aren't submitted. |
data | FormData | null | Form data at the moment the step was entered. Used to show what was entered on a summary/confirm step. |
getData | () => FormData | Current data of the form. |
WizardStep
interfaceA step inside Wizard.
| Name | Type | Description |
|---|---|---|
label | ReactNode | Name in the step indicator. |
description? | ReactNode | Short description below the name. |
icon? | IconProp | Icon shown instead of the number: name or element. |
title? | ReactNode | Title shown above the step's content. If omitted, the title is read only to screen readers (label). |
content | ReactNode | ((wizard: WizardContextValue) => ReactNode) | Content of the step: fields. If a function is given, it receives the wizard's state (e.g. data on a summary step). A function can only be passed from a client component. |
validate? | (data: FormData, wizard: WizardContextValue) => WizardValidateResult | Promise<WizardValidateResult> | Extra validation that runs after the fields' browser rules (required, type, pattern…) pass. Can return a Promise (e.g. "is this email registered?" on the server); meanwhile the Next button shows loading. See WizardValidateResult. |
optional? | boolean | Optional step: "İsteğe bağlı" is written in the indicator and a "Skip" button appears. Fields of a skipped step aren't submitted or validated. |
disabled? | boolean | The step is skipped and can't be visited. |
tooltip? | TooltipProp | Tooltip shown when hovering the step in the indicator. |
WizardLabels
interfaceButton texts of Wizard.
| Name | Type | Default | Description |
|---|---|---|---|
back? | ReactNode | "Geri" | |
next? | ReactNode | "İleri" | |
finish? | ReactNode | "Tamamla" | Submit button on the last step. |
skip? | ReactNode | "Atla" |
WizardClassNames
interfaceClasses that can be passed to the inner parts of Wizard.
| Name | Type | Description |
|---|---|---|
stepper? | string | Step indicator. |
panel? | string | Content box of each step. |
title? | string | Step title. |
footer? | string | Bottom bar holding the buttons. |
WizardProps
interfaceProps of the Wizard component.
Extends: Omit<FormProps<Schema>, "children" | "noValidate" | "onValidSubmit">
| Name | Type | Default | Description |
|---|---|---|---|
steps | readonly WizardStep[] | Steps. | |
step? | number | Index of the current step in controlled use. | |
defaultStep? | number | 0 | Initial step in uncontrolled use. |
onStepChange? | (index: number) => void | Called when the step changes. | |
linear? | boolean | true | Linear flow: you can't go to the next step without passing one; from the indicator you can only return to visited steps. With false you move freely between steps; everything is validated on submit. |
onComplete? | (data: FormData, values: FormValues<Schema>) => void | Promise<void> | Called with the form data on the last step if all steps are valid. If schema is given, the second argument is the schema's typed output. If it returns a Promise, the Complete button shows loading until it ends. If omitted, the form is submitted normally (action or onSubmit). | |
orientation? | "horizontal" | "vertical" | "horizontal" | Position of the step indicator: on top (horizontal) or on the left (vertical; moves to the top and the summary view on narrow screens). |
variant? | StepperVariant | CustomVariant<"stepper"> | "circle" | Indicator style; see StepperProps.variant. |
effect? | EffectProp | Effect of the step indicators; see StepperProps.effect. | |
labelPlacement? | "end" | "bottom" | "end" | Position of the name in the horizontal indicator. |
mobile? | StepperMobile | "compact" | View of the indicator on narrow screens. See StepperMobile. |
size? | Size | "md" | Indicator size. |
labels? | WizardLabels | Button texts. | |
footer? | ReactNode | Extra content shown in the bottom bar left of the buttons (e.g. "Save draft"). | |
stickyFooter? | boolean | false | On narrow screens the button bar sticks to the bottom of the screen; the Next button is always at hand on long steps. |
backButton? | boolean | true | The phone's or browser's back button returns to the previous step instead of leaving the page. |
warnOnLeave? | boolean | false | If the form was changed but not completed and the page is closed or reloaded, the browser shows a warning. |
classNames? | WizardClassNames | Classes added to the inner parts. |