Primitives
Props and slots of every Stepper component.
All primitives pass class, style and every other attribute to the element
they render. On Root, List, Item, Content and Indicator, an attribute
you pass replaces the one the primitive would set (class and style are
merged, listeners chained). On Trigger, Prev and Next, the ids, roles,
tabindex, disabled, ARIA and data-* attributes the primitive manages take
precedence, so the buttons stay in step with the flow; only the default
type="button" gives way to yours.
All except Root accept as-child to
use your own element:
one child, which receives the props, and is filled with the primitive's
default content when it is empty.
A template ref on a primitive is its component instance; the element is
ref.value.$el. With as-child it is the element your child rendered. A
Content whose step is not current renders nothing, so its $el is then a
placeholder comment.
In TSX, pass slots with v-slots to have their parameters typed.
Root
Renders a div. Creates the flow and provides it.
| Prop | Type | Description |
|---|---|---|
| Every option | linear, next, guard, snapshot, step, and onChange, onFinish, onInvalidStep (or @change, @finish, @invalid-step). | |
orientation | "horizontal" | "vertical" | Default "horizontal". |
| Slot | Props | Description |
|---|---|---|
default | The stepper | v-slot="stepper". Reactive and read-only: only what the slot reads is tracked. |
@change 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 |
|---|---|---|
orientation | "horizontal" | "vertical" | Defaults to the root's. |
| Slot | Props | Description |
|---|---|---|
item | { step, index } | Rendered once per step; items inside it need no step prop. |
default | Used when there is no item slot: write the items yourself. With as-child, your element, which the item slot fills. |
Item
Renders an li.
| Prop | Type | Description |
|---|---|---|
step | Step id | Required outside the item slot of a List. |
| Slot | Props | Description |
|---|---|---|
default | The item | v-slot="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.
Title and Description
Render a span with the step's title or description field. Slot content
replaces it. With as-child, an empty child (<h3 />) shows the field.
Indicator
Renders a span with aria-hidden. Empty by default: style it, or fill the
slot.
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. |
force-mount | 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.
It works inside <Transition>, in every mode: see
Animating panels.
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.
Your own @click runs first. Call event.preventDefault() in it to handle the
move yourself.
useItem
Stepper.useItem() returns a ComputedRef of the enclosing item.
| 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 as-child that loses its props
(SZ001): no element in the slot, more than one
node, a component that does not pass its attributes on, or a List element
that is not empty while the item slot should fill it. They also warn about a
trigger without an accessible name (SZ002), a
trigger outside a List (SZ003) and a trigger
that is not a button (SZ005).
Last updated on