GhostStepper
GhostStepper shows the steps of a multi-step task, such as a booking wizard, onboarding or checkout. It says which step is current, which are complete, which are still to do and which hold errors, and it lets the user move between the steps they are allowed to reach. Import it from @ghostvue/themes for the default styling; the behavior and semantics come from the headless component in @ghostvue/vue. The stepper owns the step list, the states, the reachability rule and the accessible text. Your app owns the step content, validation and what "complete" means. To style it yourself, see Advanced: headless composition.
A screen reader user tabbing through a five-step booking hears "Step 3 of 5, Guests, button, current step" instead of a tab.
Book a stay
Five-step hotel booking on one useGhostForm: each step validates before moving forward, completed steps stay reachable, and a server error marks the Contact step.
The wizard keeps one form for all five steps (from useGhostForm) and renders only the current step's fields. The stepper is controlled: the app keeps the current value and a set of completed steps, and maps them into steps in a computed.
const steps = computed(() =>
wizard.map((step) => ({
...step,
completed: completed.value.has(step.value),
invalid: step.fields.some((path) => form.isFieldInvalid(path)),
})),
)The stepper's update:modelValue, Next and Back all call one goTo function. Moving forward validates the step being left one field at a time, then decides from the form's committed state; going back never validates.
let request = 0
async function goTo(target: StepValue) {
const id = ++request
const from = wizard[indexOf(current.value)]
if (indexOf(target) > indexOf(current.value)) {
for (const path of from.fields) await form.validateField(path)
if (id !== request) return // a newer move superseded this one
if (form.isPending.value) return
if (from.fields.some((path) => form.isFieldInvalid(path))) return
completed.value = new Set(completed.value).add(from.value)
}
current.value = target
await nextTick()
heading.value?.focus() // tabindex="-1" heading of the new step
}- Validate one field after another. Each
validateFieldcall starts a whole-schema pass, and a newer pass supersedes an older one, so the calls must not run in parallel. - Decide from committed state, not return values. A
validateFieldcall whose pass was superseded (for example, by an edit while an async schema runs) resolves to no issues, exactly like a passing one. Checkingform.isPendingandform.isFieldInvalidafter the last call catches it. If the last pass is itself superseded and still running, the move is refused and the user presses Next again. See Known limitations. - Latest wins. The
requestcounter drops a slow move that a newer one overtook, such as Next followed by a quick click on step 1. - Server errors. When the server rejects the email on submit, the app calls
setFieldErrors('email', …). Step 4 turns invalid ("Has errors") while staying complete and reachable, and the app setscurrenttocontactdirectly (a programmatic move, so no validation runs) and focuses the email field. Trytaken@example.comin the example.
Do not bind the stepper's disabled prop to a pending move: disabling every trigger would drop keyboard focus to the page. While the move is pending, the stepper keeps showing the old step, and focus stays on the trigger the user pressed.
Next and Back
Controlled three-step account setup where the stepper, Next and Back all call one goTo function.
Pass :model-value and handle @update:model-value to keep the current step in your app. Activating a reachable trigger emits the target step's value and changes nothing until the parent applies it, so a parent that refuses the move (because validation failed) leaves the stepper where it was. Activating the current step does nothing.
Programmatic moves are never restricted: the app may set the value to any step, including a disabled one. With steps declared as const, v-model carries the literal union of their values ('account' | 'workspace' | …) with no cast.
Without modelValue, the stepper is uncontrolled: it starts at defaultValue (or the first step) and moves when the user activates a trigger. Uncontrolled mode has no programmatic move, so use it only when the stepper's own triggers are the only navigation:
<GhostStepper :steps="sections" navigation="free" aria-label="Sections" />Which steps can be reached
A step's trigger is reachable when neither the step nor the stepper is disabled and the navigation rule allows it. Unreachable triggers are native disabled: they leave the Tab order but screen readers still list them ("unavailable", "dimmed").
navigation | Reachable steps |
|---|---|
linear (default) | Any step at or before the current one, any completed step, and the first step that is neither completed nor disabled (the next step to do). |
free | Every enabled step. |
none | None. A status display: see Status only. |
On a fresh five-step wizard only step 1 is reachable. After step 1 is complete and the user is on step 2, steps 1 and 2 are reachable, and step 2 stays reachable if the user goes back to step 1. A disabled step (an optional step that does not apply) does not block the steps after it. invalid never affects reachability, so the user can always reach the step that holds an error.
Vertical with descriptions
Vertical onboarding checklist with a description under each step and free navigation.
orientation="vertical" stacks the steps; it changes layout only, not the keys. A step's description renders after its trigger and is linked with aria-describedby, so it is read after the name instead of lengthening it.
Status only
Checkout progress header with navigation set to none: the steps are announced but nothing is interactive.
With navigation="none", nothing is focusable. The root is a plain div, the list carries the ariaLabel, and each step is a span with the same position, label and status text, so browse mode reads "Step 3 of 4, Payment, current step". Use it for a progress header that is not a navigation.
Accessibility
| Topic | Behavior |
|---|---|
| Structure | A nav landmark named by ariaLabel (default "Steps") around an ol, one li and native button per step. |
| Trigger name | Position text ("Step 1 of 5"), the label, then status text: "Has errors" for an invalid step, "Completed" for a complete step that is not current, otherwise none. |
| Current step | aria-current="step" on its trigger only. |
| Decoration | The indicator and the separator are aria-hidden; their look never carries meaning on its own. |
| Several steppers | Give each a distinct aria-label ("Booking steps") so the landmarks can be told apart. |
| Localization | getPositionLabel(position, count) returns the position text without trailing punctuation; completeLabel and invalidLabel replace the status words. |
| Announcing a move | The stepper has no live region. Move focus to the new step's heading (a tabindex="-1" heading) after every move, as the booking example does, so the user hears where they are. If you keep focus on the trigger instead, add your own polite announcement. |
Keyboard and focus
The stepper is a list of buttons, not a composite widget: there is no roving tabindex and no arrow-key handling, so arrow keys stay with the screen reader and the page.
| Key | Behavior |
|---|---|
Tab / Shift+Tab | Moves through the enabled triggers in order, then on through the page. |
Enter / Space | Activates the focused trigger. On the current step, nothing happens. |
Activating a trigger does not move focus; your app decides where it goes. If the trigger that has focus becomes disabled or is removed (for example, the app marks a step incomplete), the stepper moves focus to the current step's trigger, or the first enabled one. Focus outside the stepper is never moved.
From Tabs
Apps that built a wizard from GhostTabs (manual activation, disabled future tabs, an error badge in a tab) can switch to the stepper:
- Map each tab to a step object and keep your panel content, rendered with
v-ifon the current value. The stepper renders no panels. - Replace
disabledtabs withcompletedflags and the linear rule. - Replace the error badge with
invalid; the stepper adds "Has errors" to the name and the theme paints the indicator. - Drop the separate
GhostProgress: "Step 3 of 5" is in every trigger's name.
Styling hooks
The themed recipe takes trigger height, label size and indicator size from the control.size tokens through size (sm, md, lg), so coarse pointers get 44px targets. A horizontal stepper measures its own width: when the labels no longer fit, non-current labels and descriptions are visually clipped, leaving the indicators and the current label, and every trigger keeps its full accessible name. Long labels can switch to orientation="vertical".
| Hook | Where |
|---|---|
data-part | root, list, item, trigger, indicator, position, label, status, description, separator |
data-orientation, data-navigation, data-disabled | Root. |
data-state (complete, current, incomplete) | Each item and trigger. |
data-completed, data-invalid, data-disabled, data-navigable | Each item and trigger, when true. data-completed marks a finished step the user went back to. |
API
@ghostvue/themes adds these to the headless GhostStepper API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | "md" | Trigger min height, label size and indicator size from control.size tokens. Default omits data-size. |
| Prop | Type | Default | Description |
|---|---|---|---|
ariaLabel | string | "Steps" | Accessible name of the nav root, or of the list when navigation is none. |
completeLabel | string | "Completed" | Visually hidden status text for a complete, valid step that is not current. |
defaultValue | GhostStepperValue<TStep> | — | Initial current step when modelValue is omitted. Read once at setup. Omitted, the first step of the current steps is current until the user moves. |
disabled | boolean | false | No trigger is navigable; states and the current step stay announced. For a stepper unavailable for the whole task, not for a pending move. |
getPositionLabel | ((position: number, count: number) => string) | — | Visually hidden text that starts each trigger's accessible name. Return text without trailing punctuation; the stepper adds the separator. |
invalidLabel | string | "Has errors" | Visually hidden status text for any invalid step, including the current one. Takes precedence over completeLabel. |
modelValue | GhostStepperValue<TStep> | — | Controlled current step value. Omit for uncontrolled mode. |
navigation | GhostStepperNavigation | "linear" | linear: back to any earlier step, to completed steps, and to the first step that is neither completed nor disabled. free: every enabled step. none: status only; nothing is interactive. |
orientation | GhostStepperOrientation | "horizontal" | Layout only. Sets data-orientation. |
steps | readonly TStep[] | Required | Ordered steps. value must be unique and non-empty. Read, never mutated. |
| Slot | Slot props | Description |
|---|---|---|
description | — | Supporting text outside the trigger, referenced by aria-describedby. Defaults to step.description. When provided, it renders for every step. Receives the step context. |
indicator | — | Decoration inside the trigger's aria-hidden indicator part. Defaults to the position, ✓ for a complete valid step, and ! for an invalid one. Receives the step context (step, position, state, navigable, …). |
label | — | Visible label inside the trigger. Must render text: it is part of the trigger's accessible name. Receives the step context. |
separator | — | Decoration after every item except the last, aria-hidden. The theme draws the connector line on this part. Receives the step context. |
Step objects
steps is read, never mutated. The stepper reads only these fields; any other field on your step type reaches the slots unchanged, with its type.
| Field | Type | Description |
|---|---|---|
value | string | Stable, unique, non-empty id. Used for v-model and identity. |
label | string | Visible name, part of the trigger's accessible name. |
description | string | Optional supporting text, linked with aria-describedby. |
completed | boolean | The app considers the step done. |
invalid | boolean | The step holds errors. Independent of completed. |
disabled | boolean | The stepper never lets the user move to this step. |
Slot context
Every slot receives the step's context:
| Property | Description |
|---|---|
step | Your step object, with its own type. |
index, position, count | 0-based index, 1-based position, and the number of steps. |
state | complete, current or incomplete. |
current, completed, invalid | Booleans for the step. |
disabled | step.disabled or the stepper's disabled. |
navigable | The step's trigger can move the user there right now. |
Template ref
| Member | Description |
|---|---|
element | The root element, or null before mount. |
focus(options) | Focuses the current step's trigger when enabled, otherwise the first enabled trigger. |
blur() | Blurs the focused trigger. |
Native attributes, class and style fall through to the root. Development warnings: GHOST025 (no steps), GHOST026 (duplicate value) and GHOST027 (the value matches no step).
Advanced: headless composition
For teams that bring their own design system: the headless GhostStepper from @ghostvue/vue renders the same markup with only a flex list and the visually hidden parts, and the slots replace the indicator, label, description and separator.
Headless stepper with icon indicators and two-line labels from the indicator and label slots, styled with data-part hooks.
The label slot must render text, because it is part of the trigger's accessible name. Keep extra text (here, the hint) separated with a visually hidden ", " so the name does not run together.
Custom markup
useGhostStepper(options) returns the resolved model GhostStepper renders from. With your own elements, the accessibility contract above is yours: a named nav around an ol, native button triggers with the position, label and status text in their names, aria-current="step" on the current trigger, disabled on triggers that are not navigable, and aria-describedby for descriptions.
| Option or member | Description |
|---|---|
steps | Ref or getter of the ordered steps. |
modelValue | Ref or getter of the controlled value; undefined for uncontrolled. |
defaultValue | Initial uncontrolled value, read once. |
navigation | Ref or getter: linear, free or none. |
disabled | Ref or getter: no step is navigable. |
onUpdateModelValue | Called when select moves to a step. |
currentValue | Computed current value, or undefined when it matches no step. |
currentIndex | Computed index of the current step, or -1. |
items | Computed slot context for every step, in order. |
select(value) | Moves to a navigable step that is not current and returns whether it did. Not a way around reachability. |
Known limitations
GhostForm'svalidateFieldresolves to no issues both when the field is valid and when its pass was cancelled by a newer one. The wizard recipe works around this by deciding from committed form state, which means a forward move made while the final pass is superseded and still running is refused, and the user presses Next again. AvalidateFieldresult that reports "superseded" would let the recipe wait instead; that is a separateGhostFormchange.- The status-only mode relies on
aria-currenton aspan. Its screen reader output is part of the manual checks still to be recorded before the component leavesexperimental.
See also
GhostForm: the form the booking wizard validates with.GhostTabs: for peer views the user switches between freely.GhostProgress: a progress bar, if you also want one.- Specification