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.
| Prop | Type | Description |
|---|---|---|
| Every option | linear, next, guard, snapshot, step, onChange, onFinish, onInvalidStep. | |
orientation | "horizontal" | "vertical" | Default "horizontal". |
children | JSX.Element | (stepper) => JSX.Element | The 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.
| Prop | Type | Description |
|---|---|---|
children | JSX.Element | (step, index) => JSX.Element | The 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.
| Prop | Type | Description |
|---|---|---|
step | Step id | Required outside a List function. |
children | JSX.Element | (item) => JSX.Element | The 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.
| Prop | Type | Description |
|---|---|---|
step | Step id | Required. |
forceMount | boolean | Keep 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.
Nextcallsnext()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.Prevcallsprev(), 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.
| Field | Type | Description |
|---|---|---|
step | Step | The step, with all its fields. |
index | number | Its position. |
state | "pending" | "current" | "complete" | |
invalid | boolean | Its last validation failed and its data has not changed since. |
disabled | boolean | goTo would be refused right now. |
pending | boolean | A 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.
Last updated on