1e41f4b71Sopenharmony_ci# stepper
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci>  **NOTE**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci>  This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe **\<stepper>** component provides a step navigator. When multiple steps are required to complete a task, you can use the **\<stepper>** component to navigate your users through the whole process.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Required Permissions
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNone
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Child Components
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciOnly the **\<stepper-item>** component is supported.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci>  **NOTE**
20e41f4b71Sopenharmony_ci>
21e41f4b71Sopenharmony_ci>  Steps in the **\<stepper>** are sorted according to the sequence of its **\<stepper-item>** child components.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## Attributes
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| Name   | Type    | Default Value | Description                            |
29e41f4b71Sopenharmony_ci| ----- | ------ | ---- | ------------------------------ |
30e41f4b71Sopenharmony_ci| index | number | 0    | Index of the **\<stepper-item>** child component to display. By default, the first one is displayed.|
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## Styles
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciThe [universal styles](js-components-common-styles.md) are supported.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci>  **NOTE**
38e41f4b71Sopenharmony_ci>
39e41f4b71Sopenharmony_ci>  By default, the **\<stepper>** component fills entire space of its container. To optimize user experience, it is recommended that the container should be as large as the application window in size, or should be the root component.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## Events
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciIn addition to the [universal events](js-components-common-events.md), the following events are supported.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci| Name    | Parameter                                      | Description                                      |
47e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- | ---------------------------------------- |
48e41f4b71Sopenharmony_ci| finish | -                                       | Triggered when the last step on the navigator is complete.                   |
49e41f4b71Sopenharmony_ci| skip   | -                                       | Triggered when users click the skip button to skip steps.|
50e41f4b71Sopenharmony_ci| change | { prevIndex: prevIndex, index: index} | Triggered when users click the left or right (text) button of the step navigator to switch between steps. **prevIndex** indicates the index of the previous step, and **index** indicates that of the current step.|
51e41f4b71Sopenharmony_ci| next   | { index: index, pendingIndex: pendingIndex } | Triggered when users click the next (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in { pendingIndex: pendingIndex } format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the next step to go. |
52e41f4b71Sopenharmony_ci| back   | { index: index, pendingIndex: pendingIndex } | Triggered when users click the previous (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in Object: { pendingIndex: pendingIndex } format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the previous step. |
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci## Methods
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciIn addition to the [universal methods](js-components-common-methods.md), the following methods are supported.
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci| Name                 | Parameter                                      | Description                                      |
60e41f4b71Sopenharmony_ci| ------------------- | ---------------------------------------- | ---------------------------------------- |
61e41f4b71Sopenharmony_ci| setNextButtonStatus | { status: string, label: label } | Sets the text and status of the next button in the step navigator. **label** indicates the button text, and **status** indicates the button status. Available **status** values are as follows:<br>- **normal**: The next button is displayed normally and can navigate users to the next step when it is clicked.<br>- **disabled**: The next button is grayed out and unavailable.<br>- **waiting**: The next button is not displayed, and a process bar is displayed instead.<br>- **skip**: The skip button is displayed to allow users to skip all remaining steps.|
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci## Example
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci```html
67e41f4b71Sopenharmony_ci<!-- xxx.hml -->
68e41f4b71Sopenharmony_ci<div class="container">
69e41f4b71Sopenharmony_ci    <stepper class="stepper" id="mystepper" onnext="nextclick" onback="backclick" onchange="statuschange"
70e41f4b71Sopenharmony_ci             onfinish="finish" onskip="skip" style="height : 100%;">
71e41f4b71Sopenharmony_ci        <stepper-item class="stepper-item" label="{{ label_1 }}">
72e41f4b71Sopenharmony_ci            <div class="item">
73e41f4b71Sopenharmony_ci                <text>Page One</text>
74e41f4b71Sopenharmony_ci                <button type="capsule" class="button" value="change status" onclick="setRightButton"></button>
75e41f4b71Sopenharmony_ci            </div>
76e41f4b71Sopenharmony_ci        </stepper-item>
77e41f4b71Sopenharmony_ci        <stepper-item class="stepper-item" label="{{ label_2 }}">
78e41f4b71Sopenharmony_ci            <div class="item">
79e41f4b71Sopenharmony_ci                <text>Page Two</text>
80e41f4b71Sopenharmony_ci                <button type="capsule" class="button" value="change status" onclick="setRightButton"></button>
81e41f4b71Sopenharmony_ci            </div>
82e41f4b71Sopenharmony_ci        </stepper-item>
83e41f4b71Sopenharmony_ci        <stepper-item class="stepper-item" label="{{ label_3 }}">
84e41f4b71Sopenharmony_ci            <div class="item">
85e41f4b71Sopenharmony_ci                <text>Page Three</text>
86e41f4b71Sopenharmony_ci                <button type="capsule" class="button" value="change status" onclick="setRightButton"></button>
87e41f4b71Sopenharmony_ci            </div>
88e41f4b71Sopenharmony_ci        </stepper-item>
89e41f4b71Sopenharmony_ci    </stepper>
90e41f4b71Sopenharmony_ci</div>
91e41f4b71Sopenharmony_ci```
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci```css
94e41f4b71Sopenharmony_ci/* xxx.css */
95e41f4b71Sopenharmony_ci.container {
96e41f4b71Sopenharmony_ci    flex-direction: column;
97e41f4b71Sopenharmony_ci    align-items: center;
98e41f4b71Sopenharmony_ci    height: 100%;
99e41f4b71Sopenharmony_ci    width: 100%;
100e41f4b71Sopenharmony_ci    background-color: #f7f7f7;
101e41f4b71Sopenharmony_ci}
102e41f4b71Sopenharmony_ci.stepper{
103e41f4b71Sopenharmony_ci    width: 100%;
104e41f4b71Sopenharmony_ci    height: 100%;
105e41f4b71Sopenharmony_ci}
106e41f4b71Sopenharmony_ci.stepper-item {
107e41f4b71Sopenharmony_ci    width: 100%;
108e41f4b71Sopenharmony_ci    height: 100%;
109e41f4b71Sopenharmony_ci    flex-direction: column;
110e41f4b71Sopenharmony_ci    align-items: center;
111e41f4b71Sopenharmony_ci}
112e41f4b71Sopenharmony_ci.item{
113e41f4b71Sopenharmony_ci    width: 90%;
114e41f4b71Sopenharmony_ci    height: 86%;
115e41f4b71Sopenharmony_ci    margin-top: 80px;
116e41f4b71Sopenharmony_ci    background-color: white;
117e41f4b71Sopenharmony_ci    border-radius: 60px;
118e41f4b71Sopenharmony_ci    flex-direction: column;
119e41f4b71Sopenharmony_ci    align-items: center;
120e41f4b71Sopenharmony_ci    padding-top: 160px;
121e41f4b71Sopenharmony_ci}
122e41f4b71Sopenharmony_citext {
123e41f4b71Sopenharmony_ci    font-size: 78px;
124e41f4b71Sopenharmony_ci    color: #182431;
125e41f4b71Sopenharmony_ci    opacity: 0.4;
126e41f4b71Sopenharmony_ci}
127e41f4b71Sopenharmony_ci.button {
128e41f4b71Sopenharmony_ci    width: 40%;
129e41f4b71Sopenharmony_ci    margin-top: 100px;
130e41f4b71Sopenharmony_ci    justify-content: center;
131e41f4b71Sopenharmony_ci}
132e41f4b71Sopenharmony_ci```
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```js
135e41f4b71Sopenharmony_ci// xxx.js
136e41f4b71Sopenharmony_ciimport prompt from '@ohos.promptAction';
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ciexport default {
139e41f4b71Sopenharmony_ci    data: {
140e41f4b71Sopenharmony_ci        label_1:
141e41f4b71Sopenharmony_ci        {
142e41f4b71Sopenharmony_ci            prevLabel: 'BACK',
143e41f4b71Sopenharmony_ci            nextLabel: 'NEXT',
144e41f4b71Sopenharmony_ci            status: 'normal'
145e41f4b71Sopenharmony_ci        },
146e41f4b71Sopenharmony_ci        label_2:
147e41f4b71Sopenharmony_ci        {
148e41f4b71Sopenharmony_ci            prevLabel: 'BACK',
149e41f4b71Sopenharmony_ci            nextLabel: 'NEXT',
150e41f4b71Sopenharmony_ci            status: 'normal'
151e41f4b71Sopenharmony_ci        },
152e41f4b71Sopenharmony_ci        label_3:
153e41f4b71Sopenharmony_ci        {
154e41f4b71Sopenharmony_ci            prevLabel: 'BACK',
155e41f4b71Sopenharmony_ci            nextLabel: 'NEXT',
156e41f4b71Sopenharmony_ci            status: 'normal'
157e41f4b71Sopenharmony_ci        }
158e41f4b71Sopenharmony_ci    },
159e41f4b71Sopenharmony_ci    setRightButton(e) {
160e41f4b71Sopenharmony_ci        this.$element('mystepper').setNextButtonStatus({
161e41f4b71Sopenharmony_ci            status: 'waiting', label: 'SKIP'
162e41f4b71Sopenharmony_ci        });
163e41f4b71Sopenharmony_ci    },
164e41f4b71Sopenharmony_ci    nextclick(e) {
165e41f4b71Sopenharmony_ci        var index = {
166e41f4b71Sopenharmony_ci            pendingIndex: e.pendingIndex
167e41f4b71Sopenharmony_ci        }
168e41f4b71Sopenharmony_ci        return index;
169e41f4b71Sopenharmony_ci    },
170e41f4b71Sopenharmony_ci    backclick(e) {
171e41f4b71Sopenharmony_ci        var index = {
172e41f4b71Sopenharmony_ci            pendingIndex: e.pendingIndex
173e41f4b71Sopenharmony_ci        }
174e41f4b71Sopenharmony_ci        return index;
175e41f4b71Sopenharmony_ci    },
176e41f4b71Sopenharmony_ci    statuschange(e) {
177e41f4b71Sopenharmony_ci        prompt.showToast({
178e41f4b71Sopenharmony_ci            message: 'Previous step index' + e.prevIndex + 'Current step index' + e.index
179e41f4b71Sopenharmony_ci        })
180e41f4b71Sopenharmony_ci    },
181e41f4b71Sopenharmony_ci    finish() {
182e41f4b71Sopenharmony_ci        prompt.showToast({
183e41f4b71Sopenharmony_ci            message:'Finished.'
184e41f4b71Sopenharmony_ci        })
185e41f4b71Sopenharmony_ci    },
186e41f4b71Sopenharmony_ci    skip() {
187e41f4b71Sopenharmony_ci        prompt.showToast({
188e41f4b71Sopenharmony_ci            message: 'Skip triggered'
189e41f4b71Sopenharmony_ci        })
190e41f4b71Sopenharmony_ci    }
191e41f4b71Sopenharmony_ci}
192e41f4b71Sopenharmony_ci```
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci![](figures/stepper.gif)
195