Multi step and dynamic progress indicator for react
npm install react-step-progress> Multi step and dynamic progress indicator for react. Built using typescript, hooks and lots-o'-ā and lots-o'-ā¤ļø .
> Uses CSS modules so you don't have to worry about your CSS class names clashing with ours
```
npm install --save react-step-progress
> NOTE: I'm working towards an implementation where you don't have to import the stylesheet explicitly. I feel like that's not an ideal solution. Feel free to help me out š
`javascript
// import the progress bar
import StepProgressBar from 'react-step-progress';
// import the stylesheet
import 'react-step-progress/dist/index.css';
// setup the step content
const step1Content =
// setup step validators, will be called before proceeding to the next step
function step2Validator() {
// return a boolean
}
function step3Validator() {
// return a boolean
}
function onFormSubmit() {
// handle the submit logic here
// This function will be executed at the last step
// when the submit button (next button in the previous steps) is pressed
}
// render the progress bar
onSubmit={onFormSubmit}
steps={[
{
label: 'Step 1',
subtitle: '10%',
name: 'step 1',
content: step1Content
},
{
label: 'Step 2',
subtitle: '50%',
name: 'step 2',
content: step2Content,
validator: step2Validator
},
{
label: 'Step 3',
subtitle: '100%',
name: 'step 3',
content: step3Content,
validator: step3Validator
}
]}
/>;
`
- startingStep (number) - the index of the step at which to start
- steps (ProgressStep[]) - array of steps with each step containing a label, name and content
- onSubmit (function) - function to be executed on the last step, simulating the submit of the form
- wrapperClass (string) - CSS class name for progress wrapper element
- progressClass (string) - CSS class name for progress bar elementstring
- stepClass () - CSS class name for step indicatorstring
- labelClass () - CSS class name for step labelstring
- subtitleClass () - CSS class name for step subtitlestring
- contentClass () - CSS class name for step content elementstring
- buttonWrapperClass () - CSS class name for action buttons wrapper elementstring
- primaryBtnClass () - CSS class name for primary themed buttonstring
- secondaryBtnClass () - CSS class name for secondary themed buttonstring
- previousBtnName () - Change the text inside the previous buttonstring`) - Change the text inside the next button
- nextBtnName (
š¤ Gaurav Saini
- Github: @saini-g
- LinkedIn: @saini-g
Give a āļø if this project helped you!