Skip to content

Commit b415bb1

Browse files
committed
updated readme file
1 parent 9cb52fb commit b415bb1

File tree

2 files changed

+72
-74
lines changed

2 files changed

+72
-74
lines changed

README.md

Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
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+
![image](./src/assets/vertical-stepper-example.png)
66

7-
>A fully customizable ready to use vertical stepper UI package.
7+
A fully customizable ready to use vertical stepper UI package for React.
8+
Try tweaking a vertical stepper using this codesandbox link <a href="https://codesandbox.io/s/vertical-stepper-demo-x24q7u" >here</a>
89

910
## Installation
1011

11-
```
12+
```bash
1213
npm install react-vertical-stepper
1314
```
1415

@@ -17,67 +18,56 @@ You’ll need to install React separately since it isn't included in the package
1718
## Usage
1819

1920
React Vertical Stepper can run in a very basic mode by just providing the `steps` and `currentStepIndex` props like this:
20-
```
21+
22+
```jsx
23+
import React, { useState } from 'react';
2124
import Stepper from 'react-vertical-stepper';
2225

23-
<Stepper
24-
steps={stepsArray}
25-
currentStepIndex={currentStepIndex}
26-
/>
26+
function App() {
27+
const [currentStepIndex, setCurrentStepIndex] = useState(0);
28+
29+
stepsArray = [{
30+
label: 'Step 1',
31+
description: 'This is Step 1',
32+
status: 'completed'
33+
},{
34+
label: 'Step 2',
35+
description: 'This is Step 2',
36+
status: 'visited'
37+
},{
38+
label: 'Step 3',
39+
description: 'This is Step 3',
40+
status: 'unvisited'
41+
}];
42+
43+
return (
44+
<Stepper
45+
steps={stepsArray}
46+
currentStepIndex={currentStepIndex}
47+
/>
48+
);
49+
}
50+
51+
export default App;
2752
```
28-
Here the steps array is an array of objects with basic keys like
53+
The `steps` array is an array of objects with basic keys like
2954

3055
- `label` - a string that can be shown as step label title to your step indicator
3156
- `description` - a string that can be show as step description below the step label
3257
- `status` - can be provided with any of `visited`, `unvisited`, `completed`. Will be required if you are using default styles.
3358

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:
59+
>Note: You can also add any other keys to the step object and other statuses like `skipped` for different customizations as per requirements
3760
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-
};
61+
You can customize the step indicator bubble with your own DOM element using the `renderBubble` prop
6462

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-
```
63+
```jsx
7364
<Stepper
7465
steps={stepsArray}
7566
currentStepIndex={currentStepIndex}
7667
renderBubble={(step, stepIndex) => (<div key={stepIndex}>{step.label}</div>)}
7768
/>
7869
```
79-
80-
>Note: The `step` param provided by the `renderBubble` callback is the same object you pass as array item in `steps` prop.
70+
The `step` param provided by the `renderBubble` callback is the same object you pass as array item in `steps` prop.
8171

8272
## Props
8373

@@ -94,17 +84,13 @@ Props that can be passed to the component are listed below:
9484
<tbody>
9585
<tr>
9686
<td><code><b>steps:</b> object[]</code></td>
97-
<td>
98-
An array of step objects to render.
99-
</td>
87+
<td>An array of step objects to render.</td>
10088
<td><code>undefined</code></td>
10189
</tr>
10290
<tr>
10391
<td><code><b>currentIndex:</b> number</code></td>
104-
<td>
105-
The index of current active step.
106-
</td>
107-
<td>0</td>
92+
<td>The index of current active step.</td>
93+
<td><code>0</code></td>
10894
</tr>
10995
<tr>
11096
<td><code><b>onStepClick?:</b> (step: object, stepIndex: number): void</code></td>
@@ -139,26 +125,38 @@ Props that can be passed to the component are listed below:
139125

140126
## Style Customizations
141127

142-
All the default styles provided by this package are overridable using the `style` prop.
128+
All the default styles provided by this package are overridable using the `style` prop
143129
the 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-
```
161130

131+
```jsx
132+
import React from 'react';
133+
import Stepper from 'react-vertical-stepper';
134+
135+
function App() {
136+
137+
const stylesOverrride = {
138+
LabelTitle: (step, stepIndex) => ({...styles}),
139+
ActiveLabelTitle: (step, stepIndex) => ({...styles}),
140+
LabelDescription: (step, stepIndex) => ({...styles}),
141+
ActiveLabelDescription: (step, stepIndex) => ({...styles}),
142+
LineSeparator: (step, stepIndex) => ({...styles}),
143+
InactiveLineSeparator: (step, stepIndex) => ({...styles}),
144+
Bubble: (step, stepIndex) => ({...styles}),
145+
ActiveBubble: (step, stepIndex) => ({...styles}),
146+
InActiveBubble: (step, stepIndex) => ({...styles}),
147+
};
148+
return (
149+
<Stepper
150+
steps={stepsArray}
151+
currentStepIndex={currentStepIndex}
152+
styles={stylesOverrride}
153+
/>
154+
);
155+
}
156+
157+
export default App;
158+
```
159+
162160
- `LabelTitle` - overrides the step label style
163161
- `ActiveLabelTitle` - overrides the step label style of current active step
164162
- `LabelDescription` - overrides the step description style
17.1 KB
Loading

0 commit comments

Comments
 (0)