Vue Stepper - Implement a Wizard
This tutorial uses a Stepper widget to create a wizard-like application. The created application integrates the Form and MultiView components.
This wizard includes three key parts:
- The Stepper component.
- Step content where the MultiView component shows content for each step. Every view with input fields contains a Form.
- A navigation panel with an active step caption ("Step 1 of 5") and buttons for moving between steps ("Next" and "Back").

To view the complete code of this example, refer to the following demo:
Set Up App Layout
To get started, add a Stepper and a MultiView to your project. Create a navigation panel - a container with child items. Child items are a <div> element that displays the active step caption and two Buttons:
- <template>
- <DxStepper ... >
- <DxStepperItem ...
- v-for="item of steps"
- />
- </DxStepper>
- <div class="content">
- <DxMultiView ...
- :focus-state-enabled="false"
- :animation-enabled="false"
- :swipe-enabled="false"
- >
- </DxMultiView>
- <div class="nav-panel">
- <div class="current-step">
- <span ... >
- Step <span class="selected-index">1</span> of {{ steps.length }}
- </span>
- </div>
- <div class="nav-buttons">
- <DxButton ...
- id="prevButton"
- :visible="false"
- text="Back"
- />
- <DxButton ...
- id="nextButton"
- text="Next"
- />
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import DxButton from 'devextreme-vue/button';
- import DxMultiView, { DxItem as DxMultiViewItem } from 'devextreme-vue/multi-view';
- import DxStepper, { DxItem as DxStepperItem } from 'devextreme-vue/stepper';
- import type { IItemProps } from 'devextreme-react/cjs/stepper';
- import { getInitialSteps } from './data.ts';
- // ...
- const steps = ref<IItemProps[]>(getInitialSteps());
- </script>
The "Back" button is initially hidden. A later step in this tutorial implements dynamic visibility logic (see Synchronize Steps and Navigation Panel).
Configure forms for each step with MultiView items[].template:
- <template>
- <div class="content">
- <DxMultiView ... >
- <DxMultiViewItem>
- <template #default>
- <DatesTemplate ... />
- </template>
- </DxMultiViewItem>
- <!-- Configure the rest of the forms -->
- </DxMultiView>
- </div>
- </template>
- <script setup lang="ts">
- import DatesTemplate from './DatesTemplate.vue';
- // ...
- </script>
- <template>
- <DxForm ... >
- <DxSimpleItem ... />
- </DxForm>
- </template>
This tutorial implements custom components as MultiView item templates and a custom type for form data. For more details on how this example is configured, refer to the Stepper - Form Integration demo.
Synchronize Steps and Navigation Panel
Use a separate variable and the v-model directive to synchronize selectedIndex properties of Stepper and MultiView:
- <template>
- <DxStepper ...
- v-model:selected-index="selectedIndex"
- >
- <DxStepperItem ... />
- </DxStepper>
- <div class="content">
- <DxMultiView ...
- v-model:selected-index="selectedIndex"
- >
- </DxMultiView>
- </div>
- </template>
- <script setup lang="ts">
- const selectedIndex = ref(0);
- // ...
- </script>
This example utilizes the selectedIndex variable to implement navigation panel functionality:
- The
onPrevButtonClickandonNextButtonClickhandlers move to the previous/next step by modifyingselectedIndex. - The
nextButtonTextfunction changes the text of the "Next" button to "Confirm" on the last step.
The "Confirm" button submits the form and disables user interactions with the Stepper. For details on how to disable Stepper interactions, refer to the following help topic Configure a Readonly Stepper.
After users submit the form, they can reset the wizard and start over.
- <template>
- <DxStepper ...
- :focus-state-enabled="!isStepperReadonly"
- :class="{ readonly: isStepperReadonly }"
- />
- <div class="nav-panel">
- <div class="current-step">
- <span v-if="!isConfirmed">
- Step <span class="selected-index">{{ selectedIndex + 1 }}</span> of {{ steps.length }}
- </span>
- </div>
- <div class="nav-buttons">
- <DxButton ...
- id="prevButton"
- :visible="selectedIndex !== 0 && !isConfirmed"
- @click="onPrevButtonClick"
- />
- <DxButton ...
- id="nextButton"
- :text="nextButtonText"
- @click="onNextButtonClick"
- />
- </div>
- </div>
- </template>
- <script setup lang="ts">
- // ...
- const isConfirmed = ref(false);
- const isStepperReadonly = ref(false);
- const nextButtonText = computed(() => {
- if (selectedIndex.value < steps.value.length - 1) {
- return 'Next';
- }
- return isConfirmed.value ? 'Reset' : 'Confirm';
- });
- function onPrevButtonClick() {
- selectedIndex.value -= 1;
- }
- const moveNext = () => {
- selectedIndex.value += 1;
- };
- const reset = () => {
- isConfirmed.value = false;
- selectedIndex.value = 0;
- isStepperReadonly.value = false;
- // ...
- };
- const confirm = () => {
- isConfirmed.value = true;
- isStepperReadonly.value = true;
- };
- function onNextButtonClick() {
- if (selectedIndex.value < steps.value.length - 1) {
- moveNext();
- } else if (isConfirmed.value) {
- reset();
- } else {
- confirm();
- }
- }
- </script>
Implement Validation
To configure validation, assign validation groups and specify validation rules in each MultiView form that requires validation:
- <template>
- <DxForm ...
- :validation-group="validationGroup"
- >
- <DxSimpleItem ...
- :is-required="true"
- />
- </DxForm>
- </template>
- <script setup lang="ts">
- import DxForm, { DxSimpleItem } from 'devextreme-vue/form';
- // ...
- const props = withDefaults(defineProps<{
- // ...
- validationGroup?: string;
- }>(), {
- // ...
- validationGroup: () => undefined,
- });
- </script>
- <template>
- <div class="content">
- <DxMultiView ... >
- <DxMultiViewItem>
- <template #default>
- <DatesTemplate ...
- :validation-group="validationGroups[0]"
- />
- </template>
- </DxMultiViewItem>
- </DxMultiView>
- </div>
- </template>
- <script setup lang="ts">
- const validationGroups = ['dates', 'guests', 'roomAndMealPlan'];
- // ...
- </script>
This tutorial validates steps only when users move forward. If a step fails validation, navigation operation is cancelled:
- <template>
- <DxStepper ...
- @selection-changing="onSelectionChanging"
- >
- </DxStepper>
- </template>
- <script setup lang="ts">
- import validationEngine from 'devextreme/ui/validation_engine';
- // ...
- function onSelectionChanging(e: SelectionChangingEvent) {
- const { component, addedItems, removedItems } = e;
- const { items = [] } = component.option();
- const addedIndex = items.findIndex((item: IItemProps) => item === addedItems[0]);
- const removedIndex = items.findIndex((item: IItemProps) => item === removedItems[0]);
- const isMoveForward = addedIndex > removedIndex;
- if (isMoveForward) {
- const isValid = getValidationResult(removedIndex);
- setStepValidationResult(removedIndex, isValid);
- if (isValid === false) {
- e.cancel = true;
- }
- }
- }
- const moveNext = () => {
- const isValid = getValidationResult(selectedIndex.value);
- setStepValidationResult(selectedIndex.value, isValid);
- if (isValid) {
- selectedIndex.value += 1;
- }
- };
- const getValidationResult = (index: number) => {
- if (index >= validationGroups.length) {
- return true;
- }
- return validationEngine.validateGroup(validationGroups[index]).isValid;
- };
- const setStepValidationResult = (index: number, isValid: boolean | undefined) => {
- steps.value[index].isValid = isValid;
- };
- </script>
Review the full code of this tutorial in the following demo: