Git Product home page Git Product logo

react-step-progress's Introduction

Welcome to react-step-progress ๐Ÿ‘‹

Version License: MIT

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

React Step Progress demo

Install

npm install --save react-step-progress

Usage

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 ๐Ÿ˜

// 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 = <h1>Step 1 Content</h1>;
const step2Content = <h1>Step 2 Content</h1>;
const step3Content = <h1>Step 3 Content</h1>;

// 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
<StepProgressBar
  startingStep={0}
  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
    }
  ]}
/>;

Available Props

Required

  • 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

Optional

  • wrapperClass (string) - CSS class name for progress wrapper element

  • progressClass (string) - CSS class name for progress bar element

  • stepClass (string) - CSS class name for step indicator

  • labelClass (string) - CSS class name for step label

  • subtitleClass (string) - CSS class name for step subtitle

  • contentClass (string) - CSS class name for step content element

  • buttonWrapperClass (string) - CSS class name for action buttons wrapper element

  • primaryBtnClass (string) - CSS class name for primary themed button

  • secondaryBtnClass (string) - CSS class name for secondary themed button

  • previousBtnName (string) - Change the text inside the previous button

  • nextBtnName (string) - Change the text inside the next button

  • submitBtnName (string) - Change the text inside the submit button in the last step

Author

๐Ÿ‘ค Gaurav Saini

Show your support

Give a โญ๏ธ if this project helped you!

CONTRIBUTING & CODE OF CONDUCT

See CODE_OF_CONDUCT.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.