Skip to content

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 ​

Booking wizard

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.

Dates

YYYY-MM-DD
YYYY-MM-DD

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.

ts
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.

ts
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 validateField call 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 validateField call whose pass was superseded (for example, by an edit while an async schema runs) resolves to no issues, exactly like a passing one. Checking form.isPending and form.isFieldInvalid after 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 request counter 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 sets current to contact directly (a programmatic move, so no validation runs) and focuses the email field. Try taken@example.com in 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 ​

Next and Back

Controlled three-step account setup where the stepper, Next and Back all call one goTo function.

Account: step 1 of 3

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:

vue
<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").

navigationReachable 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).
freeEvery enabled step.
noneNone. 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 with descriptions

Vertical onboarding checklist with a description under each step and free navigation.

Open task: calendar

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 ​

Status only

Checkout progress header with navigation set to none: the steps are announced but nothing is interactive.

Checkout

  1. Step 1 of 4, Cart, Completed
  2. Step 2 of 4, Shipping, Completed
  3. Step 3 of 4, Payment
  4. Step 4 of 4, Confirm

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 ​

TopicBehavior
StructureA nav landmark named by ariaLabel (default "Steps") around an ol, one li and native button per step.
Trigger namePosition 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 steparia-current="step" on its trigger only.
DecorationThe indicator and the separator are aria-hidden; their look never carries meaning on its own.
Several steppersGive each a distinct aria-label ("Booking steps") so the landmarks can be told apart.
LocalizationgetPositionLabel(position, count) returns the position text without trailing punctuation; completeLabel and invalidLabel replace the status words.
Announcing a moveThe 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.

KeyBehavior
Tab / Shift+TabMoves through the enabled triggers in order, then on through the page.
Enter / SpaceActivates 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-if on the current value. The stepper renders no panels.
  • Replace disabled tabs with completed flags 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".

HookWhere
data-partroot, list, item, trigger, indicator, position, label, status, description, separator
data-orientation, data-navigation, data-disabledRoot.
data-state (complete, current, incomplete)Each item and trigger.
data-completed, data-invalid, data-disabled, data-navigableEach 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:

PropTypeDefaultDescription
size'sm' | 'md' | 'lg'"md"Trigger min height, label size and indicator size from control.size tokens. Default omits data-size.
PropTypeDefaultDescription
ariaLabelstring"Steps"Accessible name of the nav root, or of the list when navigation is none.
completeLabelstring"Completed"Visually hidden status text for a complete, valid step that is not current.
defaultValueGhostStepperValue<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.
disabledbooleanfalseNo 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.
invalidLabelstring"Has errors"Visually hidden status text for any invalid step, including the current one. Takes precedence over completeLabel.
modelValueGhostStepperValue<TStep>—Controlled current step value. Omit for uncontrolled mode.
navigationGhostStepperNavigation"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.
orientationGhostStepperOrientation"horizontal"Layout only. Sets data-orientation.
stepsreadonly TStep[]RequiredOrdered steps. value must be unique and non-empty. Read, never mutated.
SlotSlot propsDescription
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.

FieldTypeDescription
valuestringStable, unique, non-empty id. Used for v-model and identity.
labelstringVisible name, part of the trigger's accessible name.
descriptionstringOptional supporting text, linked with aria-describedby.
completedbooleanThe app considers the step done.
invalidbooleanThe step holds errors. Independent of completed.
disabledbooleanThe stepper never lets the user move to this step.

Slot context ​

Every slot receives the step's context:

PropertyDescription
stepYour step object, with its own type.
index, position, count0-based index, 1-based position, and the number of steps.
statecomplete, current or incomplete.
current, completed, invalidBooleans for the step.
disabledstep.disabled or the stepper's disabled.
navigableThe step's trigger can move the user there right now.

Template ref ​

MemberDescription
elementThe 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.

Custom indicator Headless

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 memberDescription
stepsRef or getter of the ordered steps.
modelValueRef or getter of the controlled value; undefined for uncontrolled.
defaultValueInitial uncontrolled value, read once.
navigationRef or getter: linear, free or none.
disabledRef or getter: no step is navigable.
onUpdateModelValueCalled when select moves to a step.
currentValueComputed current value, or undefined when it matches no step.
currentIndexComputed index of the current step, or -1.
itemsComputed 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's validateField resolves 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. A validateField result that reports "superseded" would let the recipe wait instead; that is a separate GhostForm change.
  • The status-only mode relies on aria-current on a span. Its screen reader output is part of the manual checks still to be recorded before the component leaves experimental.

See also ​