Not only React anymoreStepperize now runs in Vue, Svelte, Solid, Angular, Lit, and HTML
Skip to Content
Stepperize

Accessibility

What the Vue primitives handle for you, and the few things only you can provide.

The primitives are accessible without configuration. This page lists what they do, so you know what is covered and what is left to you.

The pattern follows the flow

There is no single correct markup for a stepper, so the primitives pick it from how the flow behaves.

FlowMarkup
linearAn ordered list of steps. The triggers are plain buttons; the current one has aria-current="step", and steps that are not reachable yet are disabled. Each panel is a group named after the step's title.
Free navigation, with triggersTabs: tablist, tab and tabpanel, linked with aria-controls and aria-labelledby. Each tab has aria-posinset and aria-setsize; the li around it is presentation.
No triggersNo tabs either: each panel is a group named after the step's title.

A linear flow is not a set of tabs: its steps cannot be opened in any order, and announcing them as tabs would promise that they can.

Stepper.Root decides from linear and from how many Stepper.Triggers are mounted. Until it mounts it assumes triggers, so server HTML and the first render agree; a root that mounts with none switches its panels to groups. A trigger shown later with v-if turns them back into tabs.

What is handled

BehaviorDetail
KeyboardIn tabs, arrow keys, Home and End move between steps, and the selected tab is the list's single tab stop. Left and right swap in right-to-left layouts, up and down apply with orientation="vertical". With Alt, Ctrl or Meta held, the keys are left to the browser. A tab you disabled is skipped. In a linear flow the triggers are ordinary buttons in the tab order.
FocusIf focus would be lost after a step change (a field in a panel that unmounted, a button that became disabled, a panel hidden by force-mount), it moves to the new panel. Focus outside the stepper is never moved.
AnnouncementsWhen the step changes while focus stays put, for example on Next, a polite live region inside the root announces the new step's title. When focus is already on the new step's tab or panel, which reads it anyway, nothing is announced.
Async checksWhile a schema, guard or onFinish runs, the buttons keep focus: they are aria-disabled rather than disabled, and the root has aria-busy.
Valid markupTitle and Description are spans, so they are valid inside the trigger's button. Indicator has aria-hidden.
IdsBuilt from Vue's useId(), so aria-controls and aria-labelledby match between the server and the client, and two steppers on a page never share one.

<Transition> around panels

Focus and announcements work with Vue's <Transition> in every mode. With mode="out-in" the new panel mounts only after the old one has left: if focus was in the leaving panel, both the focus move and the announcement wait for the new panel, so the step is read once. Focus you moved elsewhere in the meantime stays there. Respect reduced motion in your transition CSS; see Styling.

What only you can provide

  • A name for every trigger. Stepper.Indicator is hidden from screen readers. If a trigger only shows a number or an icon, name it from the #item slot:

    <template #item="{ step, index }">
      <Stepper.Item>
        <Stepper.Trigger :aria-label="step.title">
          <Stepper.Indicator>{{ index + 1 }}</Stepper.Indicator>
        </Stepper.Trigger>
      </Stepper.Item>
    </template>
  • A name for the stepper. The root is a group labelled "Stepper". Pass aria-label or aria-labelledby to describe the flow, and to translate it: on Root your attribute wins.

    <h2 id="checkout-title">Checkout</h2>
    <Stepper.Root aria-labelledby="checkout-title">…</Stepper.Root>
  • Completion beyond color. data-state is for styling. Add text for screen readers, in your language, from the item slot:

    <Stepper.Item v-slot="item">
      <Stepper.Trigger>
        <Stepper.Indicator />
        <Stepper.Title />
        <span v-if="item.state === 'complete'" class="sr-only">(completed)</span>
      </Stepper.Trigger>
    </Stepper.Item>
  • A string title on every step. Announcements and the names of panels without triggers come from it. A step without one is not announced.

  • Error messages next to their fields. stepper.issues() gives you the messages; connect them to the inputs with aria-describedby and aria-invalid. Vue's useId() gives you an id that is stable on the server too:

    <script setup lang="ts">
    import { useId } from "vue";
    import { signup } from "./signup";
    
    const stepper = signup.useStepperContext();
    const errorId = useId();
    </script>
    
    <template>
      <label>
        Email
        <input
          type="email"
          :aria-invalid="stepper.issues('account') ? true : undefined"
          :aria-describedby="stepper.issues('account') ? errorId : undefined"
        />
      </label>
      <p v-if="stepper.issues('account')" :id="errorId" role="alert">
        {{ stepper.issues("account")?.[0]?.message }}
      </p>
    </template>

    The stepper's own live region only announces step changes. A message that appears on a rejected Continue needs role="alert" (or a live region of yours) to be heard, because focus stays on the button.

  • What a finished flow says. data-finished on the root is styling only. When onFinish settles, show a confirmation and move focus to it, or put it in a live region.

Your own elements

as-child hands roles, ids, ARIA and handlers to the element in the slot. Keep these in mind:

  • Triggers, Prev and Next stay buttons. Put as-child on a <button> or a component that renders one. A trigger that is not a button cannot be pressed with Enter or Space and cannot be disabled; it is reported in development.
  • Components must pass attributes on. A component with inheritAttrs: false has to bind v-bind="$attrs" on its element, or the ARIA attributes are lost. This is reported as SZ001.
  • On Trigger, Prev and Next, the primitive's ARIA wins. Ids, roles, tabindex, disabled and ARIA attributes follow the flow; only type gives way to yours. On Root, List, Item, Content and Indicator, your attributes win, so a role or aria-label you pass there replaces the primitive's. Do not pass id to Content: the tab's aria-controls points at the one the primitive gives it.

Development checks

In development, mistakes that can be detected are reported with a code: an as-child whose element dropped the props, a trigger without an accessible name, a trigger outside its list, a trigger that is not a button. See Errors and warnings.

Run an automated checker such as axe-core in your component tests to catch the rest; the testing guide shows how to query the roles above.

Edit on GitHub

Last updated on

On this page