Not only React anymoreStepperize now runs in Vue, Svelte, Solid, Angular, Lit, and HTML
Skip to Content
Stepperize

Primitives

Props of every Stepper component.

All primitives pass class, style, ref and every other attribute to the element they render. All except Root accept as to use your own element: a tag name, or a component whose props take ref. The other props, and the element ref receives, follow what as renders.

The function children of Root, List and Item run once, untracked, and must declare their parameter: a function without one is content, as in <Show>.

Root

Renders a div. Creates the flow and provides it.

PropTypeDescription
Every optionlinear, next, guard, snapshot, step, onChange, onFinish, onInvalidStep.
orientation"horizontal" | "vertical"Default "horizontal".
childrenJSX.Element | (stepper) => JSX.ElementThe function receives the reactive stepper and runs once.

onChange is the flow's callback, not the DOM event.

The element has role="group" and the name "Stepper"; pass aria-label or aria-labelledby to describe your flow. While an async check or onFinish runs it has aria-busy and data-pending; once the flow has finished it has data-finished.

List

Renders an ol.

PropTypeDescription
childrenJSX.Element | (step, index) => JSX.ElementThe function is called once per step; items inside it need no step prop. <For> works too, with a step on each item.
orientation"horizontal" | "vertical"Defaults to the root's. Arrow keys follow it: left and right, or up and down.

Item

Renders an li.

PropTypeDescription
stepStep idRequired outside a List function.
childrenJSX.Element | (item) => JSX.ElementThe function receives the reactive item.

Trigger

Renders a button that calls goTo for its step. Must be inside an Item, and should be inside a List.

It is disabled when linear does not allow reaching the step, or when you pass disabled. In a flow that is not linear it is a tab; in a linear flow it is a plain button, with aria-current="step" on the current one. It has type="button" unless you pass as: a trigger is often a link.

Title and Description

Render a span with the step's title or description field. Children replace it.

Indicator

Renders a span with aria-hidden. Empty by default: style it, or pass children.

Content

Renders a div while its step is current. It is the tabpanel of its trigger in a flow rendered as tabs, and otherwise a group named after the step's title.

PropTypeDescription
stepStep idRequired.
forceMountbooleanKeep it mounted and hidden while its step is not current.

Do not pass id: the trigger's aria-controls points at the id Content is given.

Prev and Next

Render a button.

  • Next calls next() with no argument, which validates the data stored for the current step. On the last step it finishes the flow; it is never disabled for being at the end.
  • Prev calls prev(), and is disabled when there is nowhere to go back to.

While an async check or onFinish runs, both are aria-disabled and ignore clicks, and have data-pending.

Once the flow has finished, Next is aria-disabled with data-disabled and ignores clicks, so the flow is not submitted twice. It becomes available again when the flow changes.

Both have type="button" unless as names another tag, so they never submit a form by accident; a type you pass wins.

Your own onClick runs first. Call event.preventDefault() in it to handle the move yourself.

useItem

Stepper.useItem() returns the enclosing item as a reactive object.

FieldTypeDescription
stepStepThe step, with all its fields.
indexnumberIts position.
state"pending" | "current" | "complete"
invalidbooleanIts last validation failed and its data has not changed since.
disabledbooleangoTo would be refused right now.
pendingbooleanA move is running. Every step is disabled meanwhile.

Outside an Item it throws SZ101.

Diagnostics

In development the primitives warn about an as component that does not spread its props (SZ001), a trigger without an accessible name (SZ002), a trigger outside a List (SZ003) and a trigger that is not a button (SZ005). One that cannot take ref does not compile.

Edit on GitHub

Last updated on

On this page