Vue Stepper - Getting Started

NOTE
Before you start the tutorial, ensure DevExtreme is installed in your application.

Stepper is a UI component that allows users to navigate multi-step forms and processes such as checkouts, set-up wizards, and sign-up forms.

This tutorial guides you through the following steps:

  • Add a Stepper to a page.
  • Configure the component's core settings.
  • Create six steps and specify their icons, labels, and other options.
  • Disable completed steps as a user progresses.
Embedded applications are not available for the selected DevExtreme version (v25.1).
We recommend that you upgrade to the most recent version of DevExtreme to access the latest features, bug fixes, and security updates.

Each section in this tutorial covers a single configuration step. You can find the complete source code in the following GitHub repository:

View on GitHub

Create Stepper

Add DevExtreme to your Vue application and use the code below to create a Stepper component with one step. This example utilizes the items[] array, but you can use dataSource to define steps as well. If you do not specify at least one step, Stepper will display no data.

App.vue
  • <script setup lang="ts">
  • import { reactive } from 'vue';
  • import { DxStepper, DxItem, DxStepperTypes } from 'devextreme-vue/stepper';
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  •  
  • const items: DxStepperTypes.Item[] = reactive([
  • {}
  • ]);
  • </script>
  • <template>
  • <DxStepper ref="stepperRef">
  • <DxItem
  • v-for="(item, index) in items"
  • :key="index"
  • />
  • </DxStepper>
  • </template>

Configure Steps

This tutorial specifies the following properties to configure Stepper steps:

  • label
    Assigns a step label.
  • icon
    Defines a step icon. For more information on the DevExteme icon library, refer to DevExtreme Icons.
  • optional
    Adds an "Optional" caption.

You can also specify the following properties:

  • isValid
    Indicates input validation state for a step.
  • text
    Defines text displayed on a step indicator.
  • hint
    Specifies step hint text that appears upon hover or long-press.
  • disabled
    Disables a step.

The code below assigns six steps to the component with different configuration options.

App.vue
  • <script setup lang="ts">
  • // ...
  • const items: DxStepperTypes.Item[] = reactive([
  • { label: 'Personal Details' },
  • { label: 'Program Selection', icon: 'detailslayout' },
  • { label: 'Campus and Start Dates', icon: 'map' },
  • { label: 'Supporting Documents', icon: 'textdocument' },
  • { label: 'Scholarship and Aid', icon: 'money', optional: true },
  • { label: 'Review and Submit', icon: 'send' }
  • ]);
  • </script>
  • <template>
  • // ...
  • </template>

Customize Steps

Specify items[].template to customize an individual step, or itemTemplate to customize all steps in the component. This tutorial replaces the first step indicator with a star.

For instructions on how to define item templates, refer to Object Structures - template.

App.vue
  • <script setup lang="ts">
  • // ...
  • const items: DxStepperTypes.Item[] = reactive([
  • { label: 'Personal Details', template: 'star' },
  • // ...
  • ]);
  • </script>
  • <template>
  • <DxStepper ref="stepperRef" @selection-changed="onSelectionChanged">
  • <DxItem
  • v-for="(item, index) in items"
  • :key="index"
  • v-bind="item"
  • :template="item.template"
  • />
  • <template #star="{ data }">
  • <div class="star dx-step-indicator"></div>
  • <div class="dx-step-caption">
  • <div class="dx-step-label">{{ data.label }}</div>
  • </div>
  • </template>
  • </DxStepper>
  • </template>
  • <style>
  • .star {
  • aspect-ratio: 1;
  • clip-path: polygon(50% 0,79% 90%,2% 35%,98% 35%,21% 90%);
  • box-shadow: 0 0 0 8px #fafafa;
  • }
  • </style>

Configure Selection

The following Stepper properties allow you to configure selection at runtime:

This tutorial uses onSelectionChanged to disable steps as users move through the component.

App.vue
  • <script setup lang="ts">
  • // ...
  • const onSelectionChanged = (e: DxStepperTypes.SelectionChangedEvent) => {
  • const newItem = e.addedItems[0];
  • const newIndex = items.findIndex((item) => item.label === newItem.label);
  • if (newIndex > 0) {
  • items[newIndex - 1].disabled = true;
  • }
  • };
  • </script>
  • <template>
  • <DxStepper ref="stepperRef" @selection-changed="onSelectionChanged">
  • <!-- ... -->
  • </DxStepper>
  • </template>