11
22# React Vertical Stepper
3+ <a href =" https://www.npmjs.com/package/react-vertical-stepper " ><img src =" https://badgen.net/npm/v/react-vertical-stepper?color=blue " alt =" npm version " ></a > <a href =" https://www.npmjs.com/package/react-vertical-stepper " ><img src =" https://img.shields.io/npm/dw/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 >
34
4- <!--
5- <a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a> -->
5+ <div align =" center " >
6+ <img src =" ./src/assets/vertical-stepper-example.png " alt =" " width =" 269 " height =" 416 " />
7+ </div >
68
7- > A fully customizable ready to use vertical stepper UI package.
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 >
811
912## Installation
1013
11- ```
14+ ``` bash
1215npm install react-vertical-stepper
1316```
1417
@@ -17,67 +20,56 @@ You’ll need to install React separately since it isn't included in the package
1720## Usage
1821
1922React Vertical Stepper can run in a very basic mode by just providing the ` steps ` and ` currentStepIndex ` props like this:
20- ```
23+
24+ ``` jsx
25+ import React , { useState } from ' react' ;
2126import Stepper from ' react-vertical-stepper' ;
2227
23- <Stepper
24- steps={stepsArray}
25- currentStepIndex={currentStepIndex}
26- />
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 ;
2754```
28- Here the steps array is an array of objects with basic keys like
55+ The ` steps ` array is an array of objects with basic keys like
2956
3057- ` label ` - a string that can be shown as step label title to your step indicator
3158- ` description ` - a string that can be show as step description below the step label
3259- ` status ` - can be provided with any of ` visited ` , ` unvisited ` , ` completed ` . Will be required if you are using default styles.
3360
34- > You can also add other keys to the step object and other statuses like ` skipped ` for different customizations as per requirements
35-
36- An example for steps array is shown below:
61+ > Note: You can also add any other keys to the step object and other statuses like ` skipped ` for different customizations as per requirements
3762
38- ```
39- stepsArray = [
40- {
41- label: 'Step 1',
42- description: 'This is Step 1',
43- status: 'visited'
44- },
45- {
46- label: 'Step 2',
47- description: 'This is Step 2',
48- status: 'unvisited'
49- },
50- {
51- label: 'Step 3',
52- description: 'This is Step 3',
53- status: 'completed'
54- }
55- ];
56- ```
57- You can use ` onStepClick ` event handler which fires each time you click on a step or its label or description
58- ```
59- const [activeStepIndex, setActiveStepIndex] = useState(0);
60-
61- const handleStepClick = (step, stepIndex) => {
62- setActiveStepIndex(stepIndex);
63- };
63+ You can customize the step indicator bubble with your own DOM element using the ` renderBubble ` prop
6464
65- <Stepper
66- steps={stepsArray}
67- currentStepIndex={activeStepIndex}
68- onStepClick={handleStepClick}
69- />
70- ```
71- You can also customize the step indicator bubble with your own DOM element using the ` renderBubble ` prop
72- ```
65+ ``` jsx
7366< Stepper
7467 steps= {stepsArray}
7568 currentStepIndex= {currentStepIndex}
7669 renderBubble= {(step , stepIndex ) => (< div key= {stepIndex}> {step .label }< / div> )}
7770/ >
7871```
79-
80- > Note: The ` step ` param provided by the ` renderBubble ` callback is the same object you pass as array item in ` steps ` prop.
72+ The ` step ` param provided by the ` renderBubble ` callback is the same object you pass as array item in ` steps ` prop.
8173
8274## Props
8375
@@ -94,17 +86,13 @@ Props that can be passed to the component are listed below:
9486 <tbody >
9587 <tr>
9688 <td><code><b>steps:</b> object[]</code></td>
97- <td>
98- An array of step objects to render.
99- </td>
89+ <td>An array of step objects to render.</td>
10090 <td><code>undefined</code></td>
10191 </tr>
10292 <tr>
10393 <td><code><b>currentIndex:</b> number</code></td>
104- <td>
105- The index of current active step.
106- </td>
107- <td>0</td>
94+ <td>The index of current active step.</td>
95+ <td><code>0</code></td>
10896 </tr>
10997 <tr>
11098 <td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
@@ -139,26 +127,38 @@ Props that can be passed to the component are listed below:
139127
140128## Style Customizations
141129
142- All the default styles provided by this package are overridable using the ` style ` prop.
130+ All the default styles provided by this package are overridable using the ` style ` prop
143131the below code shows all the overridable styles:
144- ```
145- <Stepper
146- steps={stepsArray}
147- currentStepIndex={currentStepIndex}
148- styles={{
149- LabelTitle: (step, stepIndex) => ({...styles}),
150- ActiveLabelTitle: (step, stepIndex) => ({...styles}),
151- LabelDescription: (step, stepIndex) => ({...styles}),
152- ActiveLabelDescription: (step, stepIndex) => ({...styles}),
153- LineSeparator: (step, stepIndex) => ({...styles}),
154- InactiveLineSeparator: (step, stepIndex) => ({...styles}),
155- Bubble: (step, stepIndex) => ({...styles}),
156- ActiveBubble: (step, stepIndex) => ({...styles}),
157- InActiveBubble: (step, stepIndex) => ({...styles}),
158- }}
159- />
160- ```
161132
133+ ``` jsx
134+ import React from ' react' ;
135+ import Stepper from ' react-vertical-stepper' ;
136+
137+ function App () {
138+
139+ const stylesOverrride = {
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
152+ steps= {stepsArray}
153+ currentStepIndex= {currentStepIndex}
154+ styles= {stylesOverrride}
155+ / >
156+ );
157+ }
158+
159+ export default App ;
160+ ```
161+
162162- ` LabelTitle ` - overrides the step label style
163163- ` ActiveLabelTitle ` - overrides the step label style of current active step
164164- ` LabelDescription ` - overrides the step description style
0 commit comments