1+ # React Stepper
12
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 >
44
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 " />
78</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 >
1115
1216## Installation
1317
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+
1420``` bash
15- npm install react-vertical -stepper
21+ npm install @keyvaluesystems/ react-stepper
1622```
1723
1824You’ll need to install React separately since it isn't included in the package.
1925
2026## Usage
2127
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:
2329
2430``` 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+ / >
5451```
55- The ` steps ` array is an array of objects with basic keys like
5652
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:
6054
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.
6258
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
6460
6561``` jsx
6662< Stepper
6763 steps= {stepsArray}
6864 currentStepIndex= {currentStepIndex}
69- renderBubble = {(step , stepIndex ) => ( < div key= {stepIndex}> {step .label }< / div> ) }
65+ renderNode = {(step , stepIndex ) => < div key= {stepIndex}> {step .label }< / div> }
7066/ >
7167```
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.
7370
7471## Props
7572
@@ -90,31 +87,52 @@ Props that can be passed to the component are listed below:
9087 <td><code>undefined</code></td>
9188 </tr>
9289 <tr>
93- <td><code><b>currentIndex :</b> number</code></td>
90+ <td><code><b>currentStepIndex :</b> number</code></td>
9491 <td>The index of current active step.</td>
9592 <td><code>0</code></td>
9693 </tr>
9794 <tr>
9895 <td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
9996 <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.
10198 </td>
10299 <td><code>undefined</code></td>
103100 </tr>
104101 <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>
106103 <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.
108105 </td>
109106 <td><code>undefined</code></td>
110107 </tr>
111108 <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>
113117 <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
115119 </td>
116120 <td><code>right</code></td>
117121 </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>
118136 <tr>
119137 <td><code><b>styles?:</b> object</code></td>
120138 <td>
@@ -127,44 +145,43 @@ Props that can be passed to the component are listed below:
127145
128146## Style Customizations
129147
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 :
132150
133151``` jsx
134- import React from ' react' ;
135- import Stepper from ' react-vertical- stepper' ;
152+ import React from " react" ;
153+ import Stepper from " react-stepper" ;
136154
137155function 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
152169 steps= {stepsArray}
153170 currentStepIndex= {currentStepIndex}
154171 styles= {stylesOverride}
155- / >
156- );
172+ / >
173+ );
157174}
158175
159176export default App ;
160177```
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