1
+ # React Stepper
1
2
2
- # React Vertical Stepper
3
- <a href =" https://www.npmjs.com/package/@keyvaluesystems/react-vertical-stepper " ><img src =" https://badgen.net/npm/v/@keyvaluesystems/react-vertical-stepper?color=blue " alt =" npm version " ></a > <a href =" https://www.npmjs.com/package/@keyvaluesystems/react-vertical-stepper " ><img src =" https://img.shields.io/npm/dw/@keyvaluesystems/react-vertical-stepper?label=Downloads " /></a > <a href =" https://github.com/KeyValueSoftwareSystems/react-vertical-stepper " ><img src =" https://github.com/KeyValueSoftwareSystems/react-vertical-stepper/actions/workflows/update-and-publish.yml/badge.svg " alt =" " /></a >
3
+ <a href =" https://www.npmjs.com/package/@keyvaluesystems/react-stepper " ><img src =" https://badgen.net/npm/v/@keyvaluesystems/react-stepper?color=blue " alt =" npm version " ></a > <a href =" https://www.npmjs.com/package/@keyvaluesystems/react-stepper " ><img src =" https://img.shields.io/npm/dw/@keyvaluesystems/react-stepper?label=Downloads " /></a > <a href =" https://github.com/KeyValueSoftwareSystems/react-stepper " ><img src =" https://github.com/KeyValueSoftwareSystems/react-stepper/actions/workflows/update-and-publish.yml/badge.svg " alt =" " /></a >
4
4
5
- <div align =" center " >
6
- <img src =" ./src/assets/vertical-stepper-example.png " alt =" " width =" 269 " height =" 416 " />
5
+ <div style =" display : flex ; align-items : center ;" >
6
+ <div style =" padding-left : 30px " >
7
+ <img src =" ./src/assets/vertical-stepper-example.png " alt =" " width =" 173 " height =" 281 " />
7
8
</div >
8
-
9
- A fully customizable ready to use vertical stepper UI package for React.
10
- Try tweaking a vertical stepper using this codesandbox link <a href =" https://codesandbox.io/s/vertical-stepper-demo-x24q7u " >here</a >
9
+ <div style =" padding-left : 30px " >
10
+ <img src =" ./src/assets/horizontal-stepper-example.png " alt =" " width =" 576 " height =" 132 " />
11
+ </div >
12
+ </div >
13
+ A fully customizable ready to use stepper UI package for React.
14
+ Try tweaking a stepper using this codesandbox link <a href =" https://codesandbox.io/p/sandbox/react-stepper-zp2jrs?file=%2Fsrc%2FApp.js " >here</a >
11
15
12
16
## Installation
13
17
18
+ The easiest way to use react-stepper-ui-component is to install it from npm and build it into your app with Webpack.
19
+
14
20
``` bash
15
- npm install react-vertical -stepper
21
+ npm install @keyvaluesystems/ react-stepper
16
22
```
17
23
18
24
You’ll need to install React separately since it isn't included in the package.
19
25
20
26
## Usage
21
27
22
- React Vertical Stepper can run in a very basic mode by just providing the ` steps ` and ` currentStepIndex ` props like this:
28
+ React Stepper can run in a very basic mode by just providing the ` steps ` and ` currentStepIndex ` props like this:
23
29
24
30
``` jsx
25
- import React , { useState } from ' react' ;
26
- import Stepper from ' react-vertical-stepper' ;
27
-
28
- function App () {
29
- const [currentStepIndex , setCurrentStepIndex ] = useState (0 );
30
-
31
- stepsArray = [{
32
- label: ' Step 1' ,
33
- description: ' This is Step 1' ,
34
- status: ' completed'
35
- },{
36
- label: ' Step 2' ,
37
- description: ' This is Step 2' ,
38
- status: ' visited'
39
- },{
40
- label: ' Step 3' ,
41
- description: ' This is Step 3' ,
42
- status: ' unvisited'
43
- }];
44
-
45
- return (
46
- < Stepper
47
- steps= {stepsArray}
48
- currentStepIndex= {currentStepIndex}
49
- / >
50
- );
51
- }
52
-
53
- export default App ;
31
+ < Stepper
32
+ steps= {[
33
+ {
34
+ label: " Step 1" ,
35
+ description: " This is Step 1" ,
36
+ completed: true ,
37
+ },
38
+ {
39
+ label: " Step 2" ,
40
+ description: " This is Step 2" ,
41
+ completed: false ,
42
+ },
43
+ {
44
+ label: " Step 3" ,
45
+ description: " This is Step 3" ,
46
+ completed: false ,
47
+ },
48
+ ]}
49
+ currentStepIndex= {1 }
50
+ / >
54
51
```
55
- The ` steps ` array is an array of objects with basic keys like
56
52
57
- - ` label ` - a string that can be shown as step label title to your step indicator
58
- - ` description ` - a string that can be show as step description below the step label
59
- - ` status ` - can be provided with any of ` visited ` , ` unvisited ` , ` completed ` . Will be required if you are using default styles.
53
+ The ` steps ` array is an array of objects with following keys:
60
54
61
- > Note: You can also add any other keys to the step object and other statuses like ` skipped ` for different customizations as per requirements
55
+ - ` label ` - A mandatory string representing the label/title of the step.
56
+ - ` description ` - Optional extra information or description for the step.
57
+ - ` completed ` - Boolean flag for indicating step completion status.
62
58
63
- You can customize the step indicator bubble with your own DOM element using the ` renderBubble ` prop
59
+ You can customize each step node with your own DOM element using the ` renderNode ` prop
64
60
65
61
``` jsx
66
62
< Stepper
67
63
steps= {stepsArray}
68
64
currentStepIndex= {currentStepIndex}
69
- renderBubble = {(step , stepIndex ) => ( < div key= {stepIndex}> {step .label }< / div> ) }
65
+ renderNode = {(step , stepIndex ) => < div key= {stepIndex}> {step .label }< / div> }
70
66
/ >
71
67
```
72
- The ` step ` param provided by the ` renderBubble ` callback is the same object you pass as array item in ` steps ` prop.
68
+
69
+ The ` step ` param provided by the ` renderNode ` callback is the same object you pass as array item in ` steps ` prop.
73
70
74
71
## Props
75
72
@@ -90,31 +87,52 @@ Props that can be passed to the component are listed below:
90
87
<td><code>undefined</code></td>
91
88
</tr>
92
89
<tr>
93
- <td><code><b>currentIndex :</b> number</code></td>
90
+ <td><code><b>currentStepIndex :</b> number</code></td>
94
91
<td>The index of current active step.</td>
95
92
<td><code>0</code></td>
96
93
</tr>
97
94
<tr>
98
95
<td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
99
96
<td>
100
- A step click handler that fires each time you click on a step, its label or its description .
97
+ A step click handler that fires each time you click on a step.
101
98
</td>
102
99
<td><code>undefined</code></td>
103
100
</tr>
104
101
<tr>
105
- <td><code><b>renderBubble ?:</b> (step: object, stepIndex: number): ReactElement</code></td>
102
+ <td><code><b>renderNode ?:</b> (step: object, stepIndex: number): ReactElement</code></td>
106
103
<td>
107
- A render function to customize your step indicator with your own element.
104
+ A render function to customize each step node with your own element.
108
105
</td>
109
106
<td><code>undefined</code></td>
110
107
</tr>
111
108
<tr>
112
- <td><code><b>labelPosition?:</b> 'left' | 'right'</code></td>
109
+ <td><code><b>orientation?:</b> 'horizontal' | 'vertical'</code></td>
110
+ <td>
111
+ Determines the layout of the stepper.
112
+ </td>
113
+ <td><code>vertical</code></td>
114
+ </tr>
115
+ <tr>
116
+ <td><code><b>labelPosition?:</b> 'left' | 'right' | 'top' | 'bottom'</code></td>
113
117
<td>
114
- Allows you to align step label and description to either <code>left</code> or <code>right</code> of step indicator
118
+ Allows you to align step label and description with respect to its node
115
119
</td>
116
120
<td><code>right</code></td>
117
121
</tr>
122
+ <tr>
123
+ <td><code><b>showDescriptionsForAllSteps</b> boolean</code></td>
124
+ <td>
125
+ A boolean prop specifying whether to show descriptions for all steps within the stepper.
126
+ </td>
127
+ <td><code>false</code></td>
128
+ </tr>
129
+ <tr>
130
+ <td><code><b>stepContent</b>(step: object, stepIndex: number): ReactElement</code></td>
131
+ <td>
132
+ Prop that allows for dynamic content display when the step is active
133
+ </td>
134
+ <td><code>undefined</code></td>
135
+ </tr>
118
136
<tr>
119
137
<td><code><b>styles?:</b> object</code></td>
120
138
<td>
@@ -127,44 +145,43 @@ Props that can be passed to the component are listed below:
127
145
128
146
## Style Customizations
129
147
130
- All the default styles provided by this package are overridable using the ` style ` prop
131
- the below code shows all the overridable styles:
148
+ All the default styles provided by this package can be overridden using the ` style ` prop
149
+ the below code shows all the styles that can be overridden :
132
150
133
151
``` jsx
134
- import React from ' react' ;
135
- import Stepper from ' react-vertical- stepper' ;
152
+ import React from " react" ;
153
+ import Stepper from " react-stepper" ;
136
154
137
155
function App () {
138
-
139
- const stylesOverride = {
140
- LabelTitle : (step , stepIndex ) => ({... styles}),
141
- ActiveLabelTitle : (step , stepIndex ) => ({... styles}),
142
- LabelDescription : (step , stepIndex ) => ({... styles}),
143
- ActiveLabelDescription : (step , stepIndex ) => ({... styles}),
144
- LineSeparator : (step , stepIndex ) => ({... styles}),
145
- InactiveLineSeparator : (step , stepIndex ) => ({... styles}),
146
- Bubble : (step , stepIndex ) => ({... styles}),
147
- ActiveBubble : (step , stepIndex ) => ({... styles}),
148
- InActiveBubble : (step , stepIndex ) => ({... styles}),
149
- };
150
- return (
151
- < Stepper
156
+ const stylesOverride = {
157
+ LabelTitle : (step , stepIndex ) => ({ ... styles }),
158
+ ActiveLabelTitle : (step , stepIndex ) => ({ ... styles }),
159
+ LabelDescription : (step , stepIndex ) => ({ ... styles }),
160
+ ActiveLabelDescription : (step , stepIndex ) => ({ ... styles }),
161
+ LineSeparator : (step , stepIndex ) => ({ ... styles }),
162
+ InactiveLineSeparator : (step , stepIndex ) => ({ ... styles }),
163
+ Node : (step , stepIndex ) => ({ ... styles }),
164
+ ActiveNode : (step , stepIndex ) => ({ ... styles }),
165
+ InActiveNode : (step , stepIndex ) => ({ ... styles }),
166
+ };
167
+ return (
168
+ < Stepper
152
169
steps= {stepsArray}
153
170
currentStepIndex= {currentStepIndex}
154
171
styles= {stylesOverride}
155
- / >
156
- );
172
+ / >
173
+ );
157
174
}
158
175
159
176
export default App ;
160
177
```
161
-
162
- - ` LabelTitle ` - overrides the step label style
163
- - ` ActiveLabelTitle ` - overrides the step label style of current active step
164
- - ` LabelDescription ` - overrides the step description style
165
- - ` ActiveLabelDescription ` - overrides the step description style of current active step
166
- - ` LineSeparator ` - overrides default step connector line styles
167
- - ` InactiveLineSeparator ` - overrides styles of step connector line after current active step
168
- - ` Bubble ` - overrides default styles of step indicator
169
- - ` ActiveBubble ` - overrides default styles of step indicator of current active step
170
- - ` InActiveBubble ` - overrides default styles of step indicator that has ` unvisited ` step status
178
+
179
+ - ` LabelTitle ` - overrides the step label style
180
+ - ` ActiveLabelTitle ` - overrides the step label style of current active step
181
+ - ` LabelDescription ` - overrides the step description style
182
+ - ` ActiveLabelDescription ` - overrides the step description style of current active step
183
+ - ` LineSeparator ` - overrides default step connector line styles
184
+ - ` InactiveLineSeparator ` - overrides styles of step connector line after current active step
185
+ - ` Node ` - overrides default styles of step indicator
186
+ - ` ActiveNode ` - overrides default styles of step indicator of current active step
187
+ - ` InActiveNode ` - overrides default styles of step indicator that is not completed and not active
0 commit comments