GhostStepper specification
Important
Status: Approved on 2026-12-01 by zprue743 for 0.4.0 (recorded in PR #707). This is the contract the build implements. The build's manifests are listed in the frontmatter, and the usage page documents the shipped API.
Purpose and user problems
GhostStepper is a step indicator for multi-step tasks such as a booking wizard, onboarding or checkout. It shows every step in order, says which step is current, which steps are complete, which are still to do and which hold errors, and lets the user move between the steps they are allowed to reach. A screen reader user hears "Step 3 of 5, Guests, current step" instead of a tab.
Today, apps bend GhostTabs into this role: activation-mode="manual", disabled future tabs, an error GhostBadge inside a tab and a GhostProgress above the list. That works, but:
- Tabs announce as tabs ("tab, selected, 3 of 5"), which promises a set of peer views, not an ordered task with a current position.
- Arrow keys move between tabs, but a wizard's steps are not peers: the user cannot freely arrow into a step they have not reached.
- Completed, current, upcoming and invalid states, and the rule for which steps can be reached, are hand-made in every app.
- Tabs pair each trigger with a
tabpanel, so a wizard that renders one form outside the tab panels breaks the tab relationship.
The stepper owns the step list, its states, the reachability rule, step numbering and the accessible text. The app owns the step content, validation and what "complete" means.
Non-goals
- Step panels. The stepper does not render, hide or label step content. Apps render the current step with
v-if(see the booking-wizard walkthrough). A content part would duplicateGhostTabsand force a panel structure on apps that render a single form. - Validation. The stepper does not validate, block or cancel moves itself. An app that must validate before leaving a step intercepts the controlled
v-model(see Async behavior). - A dependency on
GhostForm. The stepper reads plain step objects. The link toGhostFormis a documented recipe, not an import. - Next, Back and Submit buttons. These are ordinary app buttons; the step order is the app's own array.
- Routing. Syncing the current step with the URL is app-owned.
- A progress bar. "Step 3 of 5" is announced per step. Apps that also want a bar compose
GhostProgress. - Branching or nested steps, and step reordering. The step list is flat and in the order given.
- Changes to
GhostTabsorGhostForm.
Public API
Shape
GhostStepper is a single data-driven component, like GhostPagination, with slots for the parts apps restyle. It takes an ordered steps array. The design decision records why this beats compound parts.
Exports
Headless exports from @ghostvue/vue:
GhostStepper(generic over the step type)useGhostStepper(the resolved step model, for custom markup)- Types:
GhostStepperStep,GhostStepperValue,GhostStepperStepState,GhostStepperNavigation,GhostStepperOrientation,GhostStepperStepContext,GhostStepperProps,GhostStepperEmits,GhostStepperSlots,GhostStepperExposed,UseGhostStepperOptions,UseGhostStepperReturn
Themed exports from @ghostvue/themes:
GhostStepper, with the same behavior props, the themedsizeprop and theGhostStepperSizetype, styled byghost-stepper.cssindefault.css.
Types (exact contracts)
/** One step. Extra fields on `TStep` are passed through to slots untouched. */
export interface GhostStepperStep {
/** Stable, unique, non-empty id. Used for `v-model` and identity. */
readonly value: string
/** Visible step name. Part of the trigger's accessible name. */
readonly label: string
/** Optional supporting text, linked to the trigger by `aria-describedby`. */
readonly description?: string
/** The app considers this step done. Default `false`. */
readonly completed?: boolean
/** This step holds errors. Independent of `completed`. Default `false`. */
readonly invalid?: boolean
/** The stepper never lets the user move to this step. Default `false`. */
readonly disabled?: boolean
}
/** Position of a step relative to the current one and its completion. */
export type GhostStepperStepState = 'complete' | 'current' | 'incomplete'
/** Which steps the stepper's own triggers can move to. */
export type GhostStepperNavigation = 'linear' | 'free' | 'none'
export type GhostStepperOrientation = 'horizontal' | 'vertical'
/** Slot props and `useGhostStepper` entries for one step. */
export interface GhostStepperStepContext<TStep extends GhostStepperStep> {
readonly step: TStep
/** 0-based index in `steps`. */
readonly index: number
/** 1-based position, as announced ("Step {position} of {count}"). */
readonly position: number
readonly count: number
readonly state: GhostStepperStepState
readonly current: boolean
readonly completed: boolean
readonly invalid: boolean
/** `step.disabled` or the root `disabled` prop. */
readonly disabled: boolean
/** The step's trigger can move the user to this step right now. */
readonly navigable: boolean
}
/** The value type `v-model` carries: the `value` field of the consumer's step type. */
export type GhostStepperValue<TStep extends GhostStepperStep> = TStep['value']modelValue, defaultValue, the update:modelValue payload and select all use GhostStepperValue<TStep>, so a wizard whose steps are declared as const can bind a literal union (ref<'dates' | 'guests' | …>) with v-model and no cast. With plain GhostStepperStep objects it is string.
Props and configuration
GhostStepper (headless and themed)
| Prop | Type | Default | Contract |
|---|---|---|---|
steps | readonly TStep[] | required | Ordered steps. value must be unique and non-empty. Read, never mutated. |
modelValue | GhostStepperValue<TStep> | undefined | omitted | Controlled current step value. Omit for uncontrolled mode. |
defaultValue | GhostStepperValue<TStep> | undefined | first step's value | Initial current step when modelValue is omitted. Read once at setup. When omitted, see uncontrolled. |
navigation | GhostStepperNavigation | 'linear' | linear: reachable steps follow the linear rule. free: every enabled step is reachable. none: status only; no step is interactive. |
orientation | GhostStepperOrientation | 'horizontal' | Layout only. Sets data-orientation. Does not change keyboard behavior. |
disabled | boolean | false | No trigger is navigable. States and the current step stay visible and announced. For a stepper unavailable for the whole task, not for a pending move. |
ariaLabel | string | 'Steps' | Accessible name of the root landmark (or of the list when navigation is none). |
getPositionLabel | (position: number, count: number) => string | `Step ${p} of ${c}` | Visually hidden text that starts each trigger's accessible name. Return text without trailing punctuation; the stepper adds the separator. |
completeLabel | string | 'Completed' | Visually hidden status text after the label for a complete, valid step that is not current. |
invalidLabel | string | 'Has errors' | Visually hidden status text after the label for any invalid step, including the current one. Takes precedence over completeLabel. |
Themed GhostStepper only:
| Prop | Type | Default | Contract |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'md' | Trigger min height, label size and indicator size from control.size.<size> tokens. Renders data-size for sm and lg; omitted for md. |
Native attributes and listeners fall through to the root element. Do not pass aria-* as camelCase props; ariaLabel is the one named prop, as on GhostPagination and GhostBreadcrumb.
v-model contracts
v-model binds modelValue / update:modelValue with the current step's value. useControllableState is the write path, as on GhostTabs:
- Uncontrolled. Omitted
modelValue. Local state starts atdefaultValueand changes immediately when the user activates a navigable trigger. With nodefaultValue, and until the first activation, the current step is the first step of the currentstepsarray, resolved on every render rather than captured at setup. A stepper whosestepsarrive after setup ([]first, then fetched) therefore shows step 1 as current once they arrive, with no warning in between. - Uncontrolled mode is for steppers whose own triggers are the only navigation. It has no programmatic move:
selectrespects reachability and the exposed API has nogoTo. A wizard with Next and Back buttons, validation before a move, or a jump to a server-error step must be controlled. - Controlled. A defined
modelValue. Activation emitsupdate:modelValuewith the targetvalueand does not change local state. The current step changes only when the parent applies the value. A parent that does not apply it (for example, because validation failed) leaves the stepper unchanged. - Emits only on user activation. Changing
modelValue,stepsor any step flag from the parent never emits. - Activating the current step does nothing and emits nothing.
- Unmatched value. When the effective value matches no step (an unknown
modelValue, or the current step was removed fromsteps), no step is current, no trigger hasaria-current, and the stepper does not emit to repair it. A development warning names the value. The reachability rule treats the current index as-1. - Programmatic moves are never restricted. Reachability governs only the stepper's own triggers. The app may set
modelValueto any step, including a disabled one, for example to jump to the step that holds a server error.
Events, callbacks, slots, and exposed methods
Events:
| Event | Payload | Timing |
|---|---|---|
update:modelValue | [value: GhostStepperValue<TStep>] | Synchronously on activation of a navigable trigger whose step is not current. Never on mount. |
Slots. Each receives GhostStepperStepContext<TStep>:
| Slot | Default content | Notes |
|---|---|---|
indicator | position as text; ✓ when completed and not invalid and not current; ! when invalid | Rendered inside the trigger in an aria-hidden="true" part. Decoration only; state is announced by the status text and aria-current. |
label | step.label | Visible label inside the trigger. Must render text, because it is part of the trigger's accessible name. |
description | step.description; the part is not rendered when both the slot and the field are empty | Outside the trigger, referenced by aria-describedby. |
separator | empty | Rendered after every item except the last, inside the item, aria-hidden="true". The theme draws the connector line on this part. |
Exposed instance API (GhostStepperExposed):
element: HTMLElement | null, the root element.focus(options?: FocusOptions): voidfocuses the current step's trigger when it is enabled, otherwise the first enabled trigger. Does nothing when no trigger is enabled, includingnavigation="none".blur(): void
useGhostStepper
For custom markup, useGhostStepper(options) returns the resolved model that GhostStepper renders from. It is the escape hatch when the app needs its own element structure; the accessibility contract below is then the app's job, and the docs page states which attributes to copy.
export interface UseGhostStepperOptions<TStep extends GhostStepperStep> {
readonly steps: MaybeRefOrGetter<readonly TStep[]>
readonly modelValue: MaybeRefOrGetter<GhostStepperValue<TStep> | undefined>
readonly defaultValue?: GhostStepperValue<TStep>
readonly navigation?: MaybeRefOrGetter<GhostStepperNavigation | undefined>
readonly disabled?: MaybeRefOrGetter<boolean | undefined>
readonly onUpdateModelValue?: (value: GhostStepperValue<TStep>) => void
}
export interface UseGhostStepperReturn<TStep extends GhostStepperStep> {
/** Effective current value, or `undefined` when unmatched. */
readonly currentValue: ComputedRef<GhostStepperValue<TStep> | undefined>
/** Index of the current step, or `-1`. */
readonly currentIndex: ComputedRef<number>
readonly items: ComputedRef<readonly GhostStepperStepContext<TStep>[]>
/** Moves to `value` when its step is navigable and not current. Returns whether it did. */
readonly select: (value: GhostStepperValue<TStep>) => boolean
}select follows the same rules as activating a trigger: it emits or updates local state only for a navigable, non-current step. It is not a way around reachability; programmatic moves go through modelValue.
State model
Step state
Each step resolves to exactly one state:
current: itsvalueis the effective current value.complete: not current andcompletedistrue.incomplete: everything else. This covers upcoming steps and earlier steps the app has not marked complete.
invalid and disabled are independent flags on top of state. A step can be current and invalid (the user is fixing it), or complete and invalid (a server rejected a value on a step the user already finished).
Reachability
A step's trigger is navigable when it is enabled (neither the root nor the step is disabled) and:
navigation="free": always.navigation="none": never.navigation="linear": any of these hold, wherecurrentIndexis the current step's index (or-1) andfrontieris the index of the first step that is neither completed nor disabled (orsteps.lengthwhen there is none):- its index is at or before
currentIndex(go back freely); - it is
completed(jump to a finished step); - its index is
frontier(the next step to do, once everything before it is complete).
- its index is at or before
So on a fresh five-step wizard only step 1 is reachable. After the app marks step 1 complete and moves to step 2, steps 1 and 2 are reachable. If the user goes back to step 1, step 2 stays reachable as the frontier. An incomplete step blocks the steps after it, but a disabled step (for example, an optional step that does not apply) does not block the frontier.
invalid does not affect reachability: the user must be able to reach the step that holds the error.
Loading, empty, disabled, read-only, and error states
- Empty
steps. Renders the root and an empty list, and a development warning. No emits. - One step. Renders one item with "Step 1 of 1" and no separator.
- Disabled root. Every trigger renders native
disabled; states, the status text andaria-currentstay.data-disabledon the root. - Disabled step. That trigger renders native
disabledeven when it is the current step. - Read-only / status only.
navigation="none". See Semantics. - Error.
invalidon a step. Rendered asdata-invalid, the!indicator and theinvalidLabelstatus text. - Duplicate
values. Invalid input. A development warning names the value; the first step with that value is used for the current-step match andselect. - No loading state. Async validation is the app's (see below).
Async behavior
The stepper has no async state. It emits synchronously and renders from props. An app that validates before leaving a step uses the controlled v-model:
<GhostStepper
:steps="steps"
:model-value="current"
@update:model-value="goTo"
/>goTo may await validation and only then set current. Two moves can overlap (the user activates step 4, then step 1 before step 4's validation settles). The stepper does not order them. The documented recipe keeps a request counter and applies only the latest request, the same "latest wins" rule GhostForm uses for validation. While a move is pending, the stepper keeps showing the old current step, which is correct: the user has not left it.
Do not bind the root disabled prop to a pending move. Disabling every trigger natively would drop keyboard focus from the trigger the user just activated to <body> (see Focus behavior). The latest-wins counter already makes repeat activations safe. disabled is for a stepper that is unavailable for the whole task. The pending guard in the recipe lives inside goTo, so it covers the stepper's triggers and the Next button alike.
Consumer data
stepsis read, never mutated, sorted or copied into internal state. The stepper reads onlyvalue,label,description,completed,invalidanddisabled. Other fields onTStepreach slots unchanged throughcontext.step, with their type preserved.- Identity is
value. Description ids are derived from the stepper'suseGhostIdbase and the step's index, not fromvalue, so any string is safe as avalue. - Reactivity. Every resolved value is a
computedoverstepsand the flags. Replacing the array, or changing a field on a reactive step object, updates the stepper. Mutating a plain, non-reactive object does not. - Derived flags are the expected shape. Apps usually map their own state into
stepsin acomputed, for exampleinvalidfromGhostForm'sfieldErrors(see the walkthrough).
Accessibility contract
There is no APG stepper pattern. The structure follows the navigation landmark and list conventions used by GhostPagination and GhostBreadcrumb, with aria-current="step" for the current step.
Semantics and relationships
With navigation set to linear or free:
<nav aria-label="Steps" data-part="root">
<ol data-part="list">
<li data-part="item" data-state="complete">
<button type="button" data-part="trigger" aria-describedby="…">
<span data-part="indicator" aria-hidden="true">✓</span>
<span data-part="position">Step 1 of 5, </span>
<span data-part="label">Dates</span>
<span data-part="status">, Completed</span>
</button>
<span data-part="description" id="…">Check-in and check-out</span>
<span data-part="separator" aria-hidden="true"></span>
</li>
<li data-part="item" data-state="current">
<button type="button" data-part="trigger" aria-current="step">…</button>
</li>
<li data-part="item" data-state="incomplete">
<button type="button" data-part="trigger" disabled>…</button>
</li>
</ol>
</nav>- Root. Native
navnamed byariaLabel. Apps with more than one stepper or othernavlandmarks give each a distinct name ("Booking steps"). - List. Native
ol; each step is anli. The list gives "list, 5 items" on entry. - Trigger. Native
button type="button"in every step. Its accessible name is, in order: the position text ("Step 1 of 5"), the label, and the status text when there is one. The position and status parts are visually hidden (notdisplay: none), and their text includes the separating ", " so names never run together. - Status text.
invalidLabelfor any invalid step; otherwisecompleteLabelfor acompletestep; otherwise none. A current, valid step carries no status text becausearia-current="step"announces it. An incomplete step carries none; the disabled state already says whether it can be reached. - Current step.
aria-current="step"on the current step's trigger only. - Unreachable steps. Native
disabled. They leave the Tab order but stay in the accessibility tree, so browse mode still reads them ("unavailable" in NVDA, "dimmed" in VoiceOver). The stepper does not usearia-disabledhere, unlikeGhostPagination's edge buttons, because a locked step has no action to discover and five focusable dead stops would slow keyboard users down. - Description. Rendered outside the trigger and referenced by
aria-describedby, so it is announced after the name instead of lengthening it. - Indicator and separator.
aria-hidden="true".
With navigation="none" (a status display, for example a checkout progress header):
- The root renders a
div, not a landmark, andariaLabelmoves to theolasaria-label. - Each trigger part renders a
spanwith no role, carrying the same position, label and status text.aria-current="step"stays on the current step's span. - The description is plain list text after the trigger part.
aria-describedbyis not used in this mode, because nothing focusable would carry it. - Nothing is focusable.
- Support for
aria-currenton a role-less element is less consistent than on a button, and this mode has no other "current" signal for a valid step. The build records this mode in the manual screen reader checks. If NVDA with Firefox or VoiceOver with Safari does not announce the current step, the build adds a visually hidden current-step status text in this mode only (acurrentLabelprop, default'Current step', placed like the other status text) and keepsaria-current="step"on the span. That fallback is pre-approved by this spec; it adds one prop and changes no other behavior.
Keyboard interaction
The stepper is a list of buttons in a landmark, not a composite widget, so it uses the normal Tab order like GhostPagination. There is no roving tabindex and no arrow-key handling. Arrow keys stay with the screen reader's browse mode 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 (native button). On the current step, no-op. |
Disabled triggers are skipped. With navigation="none", no key does anything.
Focus behavior
- Activation keeps focus. After the user activates a trigger, the stepper does not move focus. The app decides whether to move it into the new step. The documented wizard moves focus to the new step's heading (a
tabindex="-1"h2) after every move, from the stepper and from Next and Back, so the user hears where they are. This is a recipe, not stepper behavior. - Focus repair. If the trigger that has focus becomes disabled or is removed (for example, the app marks a step incomplete and later steps become unreachable), the stepper moves focus, after the DOM update, to the current step's trigger, or the first enabled trigger when that is disabled. When no trigger is enabled, focus is left to the browser. Focus outside the stepper is never moved. Because that last case drops focus, apps must not bind the root
disabledprop to a pending move (see Async behavior); focus stays on the activated trigger while the app validates. - Visible focus. Every enabled trigger has a visible focus indicator in the themed recipe (
--ghost-focus-ring-*tokens). - No focus trapping.
Assistive technology expectations
Expected output, to be recorded with real screen readers by the build (see Test plan). NVDA with Firefox, tabbing through a five-step booking wizard on step 3 with step 2 holding a server error:
| Step | Stepper (expected) | Tabs workaround (today) |
|---|---|---|
| Enter the component | "Booking steps navigation landmark, list with 5 items" | "tab control" |
| 1, complete | "Step 1 of 5, Dates, Completed, button" | "Dates, tab, 1 of 5" |
| 2, complete, invalid | "Step 2 of 5, Contact, Has errors, button" | "Contact 1, tab, 2 of 5" (badge text read as part of name) |
| 3, current | "Step 3 of 5, Guests, button, current step" | "Guests, tab, selected, 3 of 5" |
| 4, incomplete (browse) | "Step 4 of 5, Room, button, unavailable" | "Room, tab, unavailable, 4 of 5" |
With navigation="none" (status only), reading the list in browse mode, the expected output for the current step is "Step 3 of 5, Guests, current step" and for a complete step "Step 1 of 5, Dates, Completed". The description is read as the next line of the list item.
VoiceOver with Safari is expected to read the same names with "current step" and "dimmed". The stepper uses no live region: a move is announced through focus (the recipe moves focus to the step heading). Apps that keep focus on the trigger after a move can add their own polite announcement.
Rendering and customization
Stable hooks, following existing data-part conventions:
- Classes:
ghost-stepperon the root; part classesghost-stepper-list,ghost-stepper-item,ghost-stepper-trigger,ghost-stepper-indicator,ghost-stepper-label,ghost-stepper-description,ghost-stepper-separator. The visually hiddenpositionandstatusparts havedata-partonly. data-ghost-stepperon the root.data-part:root,list,item,trigger,indicator,position,label,status,description,separator.- On the root:
data-orientation,data-navigation,data-disabled. - On each item and its trigger:
data-state(complete|current|incomplete), and when true,data-completed,data-invalid,data-disabled,data-navigable.data-completedlets a theme mark a current step that the user finished before going back. - Consumer
classandstyleon the root merge with the part class. - The headless component ships only the minimum layout so examples render without a theme: the list is a flex row (
horizontal) or column (vertical) with no list markers, and thepositionandstatusparts use the visually hidden style fromGhostVisuallyHidden.
Themed recipe (@ghostvue/themes):
- Indicator: a circle sized from
control.size.<size>; complete uses thestatus-successtokens, invalid uses theaction-dangertokens, current usesaction-primary, incomplete uses the neutral border. Invalid wins over complete and current for the indicator color. - Separator: a connector line between indicators, horizontal or vertical following
data-orientation; complete steps color the connector after them. - Trigger:
min-block-sizefromcontrol.size.<size>.min, so coarse pointers get the 44px minimum from the generated tokens. No fixed pixel sizes. - Narrow containers: a horizontal stepper uses a container query. Below a width where the labels no longer fit, non-current labels and descriptions are visually hidden (clip, not
display: none), so every step keeps its full accessible name and only indicators and the current label show. No horizontal scrolling. - Disabled triggers use
--ghost-action-disabled-opacity. Contrast of the indicator number and label text in every state meetspnpm contrast. - Logical properties throughout, so
dir="rtl"mirrors the horizontal layout with no extra code.
Environment behavior
SSR and hydration
- All markup comes from props. Position, count, state, reachability and status text are computed from the
stepsarray, so the server renders "Step 3 of 5" and the rightdisabledandaria-currentattributes. This is why the stepper is data-driven (see Design decision). - Description ids come from
useGhostIdand hydrate without mismatch. - No
windowordocumentaccess in setup. The focus-repair watcher runs only on the client after mount. defaultValueis read once at setup on both server and client, so an uncontrolled stepper hydrates on the same step. WithoutdefaultValue, the first step of the currentstepsis current on both sides.
Mobile and touch
- Triggers are native buttons; tap activates. No gestures.
- Target size comes from
control.sizetokens (44px under coarse pointers). - The narrow-container rule above keeps a five-step horizontal stepper inside a 390px viewport. Apps with long labels can switch to
vertical. - No virtual keyboard interaction; the stepper has no text input.
Performance
Expected scale is 2 to 10 steps. Resolving states and reachability is one O(n) pass in a computed, recomputed only when steps, a step flag, the current value, navigation or disabled changes. No observers, timers or global listeners. No virtualization.
Composition
Reused:
useControllableStatefor the current step (same contract asGhostTabsandGhostPagination).useGhostIdfor description ids.- The
GhostVisuallyHiddenstyle for thepositionandstatusparts. - Themed tokens shared with
GhostButton,GhostBadgeand the 0.4.0 control sizing work.
Deliberately not reused:
GhostTabsanduseRovingFocus. Tabs semantics and a single Tab stop with arrow keys are the problem this component replaces.GhostProgress. "Step 3 of 5" is in every trigger's name; a separateprogressbarwould repeat it. Apps that want a bar compose one.GhostForm. See below.
Optional link to GhostForm
The stepper never imports GhostForm. The link is app-side code, shown in the walkthrough and the stepper/booking-wizard example.
Entry point. The wizard uses the useGhostForm composable, spread onto a native <form> (the documented "custom form hosts" path). A script-level computed cannot read <GhostForm>'s slot props, and its template ref does not expose fieldErrors. Slot props passed into a handler are also a snapshot that goes stale after an await, because the form replaces its error object on each validation pass. useGhostForm returns fieldErrors as a ComputedRef and the live readers isFieldInvalid(path) and getFieldErrors(path), so both the steps computed and the async goTo read current state. An app that prefers <GhostForm> builds steps and goTo in a child component that receives the slot props; the docs show the composable.
- Each app step lists its field paths (
fields: ['email', 'phone']). invalidcomes from the form's errors:step.fields.some((path) => form.isFieldInvalid(path)). Only revealed errors count, so steps the user has not reached do not show as invalid early.- Before moving forward, the app calls
validateField(path)for each of the current step's paths one after another. Calls must not run in parallel: each call starts a whole-schema validation pass, and a newer pass supersedes an older one. - After the last call settles, the app decides from the form's committed state, not from the return values: it moves only when
form.isPending.valueisfalseand no path of the step is invalid (!step.fields.some((path) => form.isFieldInvalid(path))). The last pass that was not superseded commits errors for every revealed path of the step, so this catches an earlier call that was superseded by an edit and resolved to[]. - The pending guard is inside
goTo, which serves both the stepper'supdate:modelValueand the Next button, together with the latest-wins request counter from Async behavior.
One GhostForm limitation remains: if the final validateField call is itself superseded and the newer pass is still running, step 4 sees isPending and refuses the move, so the user presses Next again. A validateField result that tells "superseded" apart from "valid" would let the recipe wait instead; that is a GhostForm change, out of scope here, and recorded as a follow-up in Open architectural questions.
Booking-wizard walkthrough
Five steps: Dates, Guests, Room, Contact, Review. One form, from useGhostForm, holds all of them. The stepper is controlled. The app keeps a completed set and the current value.
const wizard = [
{ value: 'dates', label: 'Dates', fields: ['checkIn', 'checkOut'] },
{ value: 'guests', label: 'Guests', fields: ['adults', 'children'] },
{ value: 'room', label: 'Room', fields: ['roomId'] },
{ value: 'contact', label: 'Contact', fields: ['name', 'email'] },
{ value: 'review', label: 'Review', fields: [] },
] as const
type StepValue = (typeof wizard)[number]['value']
const form = useGhostForm({ schema, values, onSubmit, onInvalid })
const current = ref<StepValue>('dates')
const completed = ref(new Set<StepValue>())
const steps = computed(() =>
wizard.map((step) => ({
...step,
completed: completed.value.has(step.value),
invalid: step.fields.some((path) => form.isFieldInvalid(path)),
})),
)
const indexOf = (value: StepValue) => wizard.findIndex((s) => s.value === value)
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()
headings.value[target]?.focus() // tabindex="-1" h2 of the new step
}<GhostStepper
:steps="steps"
:model-value="current"
aria-label="Booking steps"
@update:model-value="goTo"
/>Next calls goTo(nextValue) and Back calls goTo(previousValue); the stepper calls the same function. The StepValue union flows through v-model with no cast because the value type is GhostStepperValue<TStep>.
- Start.
currentisdates. Only step 1 is navigable; steps 2 to 5 are disabled triggers. The server renders the same markup. - Move forward after the step validates. The user fills Dates and presses Next. The app validates
checkIn, thencheckOut. The form is not pending and neither path is invalid, so it addsdatestocompletedand setscurrenttoguests, then focuses the Guests heading. The stepper shows step 1complete("Completed"), step 2current, and steps 3 to 5 disabled. IfcheckOutfails, the app stays on Dates,GhostFieldshows the error, and step 1 becomesinvalidbecause its path is now revealed. Focus stays on Next. - Go back freely. On Room (steps 1 and 2 complete), the user activates step 1 in the stepper. Going back needs no validation:
goTosees the target index is lower and setscurrentimmediately. Steps 2 and 3 stay reachable: 2 is complete and 3 is the frontier. - Jump to a completed step. On Contact, with steps 1 to 3 complete, the user goes back to Dates, then activates step 3 (Room,
complete) in the stepper. The target is ahead, sogoTovalidates the Dates fields first, then moves to Room. Separately, the frontier case: on Dates with only step 1 complete, step 2 is reachable because it is the first incomplete step, and step 3 is not. - Show which step holds a server error. On Review, the user submits. The server rejects the email. In
@submit, the app callssetFieldErrors('email', ['Already registered']).fieldErrors.emailnow has a message, so step 4 rendersinvalid(indicator!, status "Has errors",data-invalid) while stayingcompleteand navigable. The app setscurrenttocontactdirectly (a programmatic move, not throughgoTo, so no validation runs) and, afternextTick, focuses the email field. A client-side failure on submit works the same way fromonInvalid: settingcurrentto the first step with an error in the handler mounts that step before the form moves focus to the first invalid control, because the form callsonInvalidbefore itsnextTickfocus step.
Design decision
Three shapes were compared against the walkthrough.
- Documented Tabs recipe. No new component. Rejected: it keeps tab semantics ("tab, selected"), arrow-key movement across steps the user has not reached, and the hand-made states that prompted the request.
- Compound parts (
GhostStepper,GhostStepperItem,GhostStepperTrigger,GhostStepperIndicator, …). Flexible, and it matchesGhostTabs. Rejected because the core promises need the whole ordered list during render: "Step 3 of 5" needs the count, and the linear rule needs the first incomplete step. Child parts only learn their siblings by registering after setup, so the server would render "Step 1" without "of 5" and every step as reachable, then correct it on the client. That is a hydration mismatch or a flash of wrong state. - Data-driven component with slots (chosen). The ordered
stepsarray gives position, count and reachability deterministically on the server and the client, the wizard already has that array, and slots plususeGhostSteppercover restyling and custom markup.GhostPaginationis the precedent.
Test plan
Unit (framework-neutral, useGhostStepper):
- State resolution:
current>complete>incomplete;invalidanddisabledindependent ofstate. - Linear reachability table: fresh wizard; after each completion; going back; a disabled incomplete step does not block the frontier; an invalid step stays reachable; unmatched current value (
currentIndex-1). free,none, rootdisabledand stepdisabled.select: returnsfalsefor the current, disabled or unreachable step, and emits or updates local state otherwise.- Duplicate values and empty
stepswarn in development and do not throw. - Uncontrolled with no
defaultValue:stepsis[]at setup and filled later; the first step becomes current with no warning and no emit.
Vue component (GhostStepper.test.ts):
- Markup per mode:
nav>ol>li>button;navigation="none"rendersdiv>ol[aria-label]>li>spanwith nothing focusable. - Accessible names: position, label and status text, with separators, for every state combination, including custom
getPositionLabel,completeLabelandinvalidLabel. aria-current="step"only on the current step; nativedisabledon unreachable and disabled steps;aria-describedbyto the description.- Controlled and uncontrolled: activation emits
update:modelValueonce; controlled state does not change until the parent applies it; a parent that rejects the value leaves the stepper unchanged; no emit on mount, on prop changes or on activating the current step. stepsupdates: insert, remove and reorder steps; remove the current step; replace the array; mutate a reactive step'scompletedandinvalid.- Focus repair: the focused trigger becomes disabled, and is removed; focus goes to the current step's trigger, or the first enabled trigger.
- Slots receive the typed context;
separatorrenders between items only. - Exposed
focus()targets andelement. - Consumer
classandstylemerge on the root. - SSR:
renderToStringgives position text,aria-current,disabledand description ids; hydration withexpectSsrHydrationhas no mismatch, including an uncontrolled stepper withdefaultValue. navigation="none": the current span keepsaria-current="step", noaria-describedbyis rendered, and the description is plain text.
Themed (@ghostvue/themes):
sizerendersdata-sizeforsmandlgonly and never reaches the DOM assize.- Themed ref reaches the root element.
Browser (tests/e2e/ghost-stepper.spec.ts):
- Press every documented key:
TabandShift+Tabvisit exactly the enabled triggers in order and skip disabled ones;EnterandSpaceactivate; assert real focus withtoBeFocused()and the resultingaria-current. - The booking-wizard example end to end: blocked forward move on a validation error, Next after a valid step, going back, jumping to a completed step (on Contact with steps 1 to 3 complete, back to Dates, then to Room), the frontier case (only the first incomplete step is reachable), the server-error step showing
data-invalidand its status text, and focus landing on the step heading or the invalid field. - Focus stays on the activated trigger while an async move is pending, and is never dropped to
<body>. - Async edit race: with an async schema, start a forward move, edit a field of the current step to an invalid value while validation runs; the step is not marked complete and the move does not happen.
- Overlapping async moves: two activations where the first validation resolves last; only the latest move applies.
- Focus repair with real focus.
- RTL: horizontal layout mirrors, Tab order follows DOM order.
- Narrow viewport (390px): no horizontal scroll; hidden labels still in the accessible name.
- Coarse pointer: every enabled trigger is at least 44px tall.
- axe with zero violations for every example, in light and dark, including
navigation="none".
Type tests (packages/vue/type-tests/GhostStepperConsumer.vue):
TStepinference: extra fields such asfieldsare typed in slot props.stepswith a missingvalueorlabelfails.navigation,orientationand themedsizereject unknown strings.v-modelwith plainGhostStepperStepobjects isstring.v-modelbound to a literal-union ref (ref<'dates' | 'guests'>) with steps declaredas constcompiles undervue-tscwith no cast, and theupdate:modelValuepayload andselectargument are that union.
Manual assistive-technology checks (planned, not recorded evidence): NVDA with Firefox and VoiceOver with Safari on the booking-wizard example and the status-only example, recording the output for each row of the table and for the navigation="none" lines in Assistive technology expectations. If the status-only check fails to announce the current step, apply the currentLabel fallback from Semantics. These are required before the manifest can move past experimental.
Documentation plan
docs/components/stepper.md: what it is for, when to use Tabs instead, the reachability rule, accessibility notes and the generated API tables.- Examples under
examples/stepper/:basic: controlled, three steps, linear, with Next and Back buttons calling onegoTo(no validation). Uncontrolled mode is shown only as anavigation="free"snippet, since it has no programmatic move.vertical: vertical orientation with descriptions.status-only:navigation="none"as a checkout progress header.booking-wizard: the five-stepuseGhostFormwalkthrough, including validation before moving forward, the server error and focus moves. This replaces the Tabs workaround.custom-indicator:indicatorandlabelslots.
- An accessibility section: the heading-focus recipe, naming multiple steppers, and localizing the position and status text.
- A "From Tabs" note for apps migrating the workaround.
- Playground section with unique copy.
- Manifests via
pnpm manifests:write, API tables viapnpm docs:api:write.
Compatibility and release impact
New, additive public API in @ghostvue/vue (GhostStepper, useGhostStepper and types) and @ghostvue/themes (GhostStepper, GhostStepperSize). Manifests start at experimental. No change to existing components, including GhostTabs and GhostForm. Changeset: minor on both packages. Target release 0.4.0.
Open architectural questions
None blocking. Decisions taken in review:
- Value type.
v-model,defaultValue, the emit payload andselectuseGhostStepperValue<TStep>(TStep['value']), notstring, so literal unions bind without a cast. - Uncontrolled mode. No programmatic move (no exposed
goTo) in0.4.0. Uncontrolled is scoped to steppers whose triggers are the only navigation; wizards are controlled. An exposed move can be added later without a breaking change. GhostFormfollow-up (non-blocking, tracked separately). A way forvalidateFieldto report that its pass was superseded, so a wizard using an async schema can wait for the newer pass instead of refusing the move. Until then the recipe decides from committed form state and refuses the move while the form is pending.