1.0.4 • Published 1 year ago

react-stepper-classic v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-stepper-classic

A customizable and modern stepper component for React.

Features

  • Fully customizable styles
  • Supports active, completed, and disabled steps
  • Custom click handlers for steps
  • Horizontal layout

Installation

npm install react-stepper-classic --save
yarn add react-stepper-classic --save

Then just add import Stepper from 'react-stepper-classic'; into your file.

Screenshot

Example Usage

import Stepper from 'react-stepper-classic';

const steps = [
  { title: 'Step 1', href: '#', onClick: () => console.log('Step 1 clicked') },
  { title: 'Step 2', href: '#', onClick: () => console.log('Step 2 clicked') },
  { title: 'Step 3', href: '#', onClick: () => console.log('Step 3 clicked') },
];

const App = () => {
  return (
    <Stepper
      activeStep={1}
      steps={steps}
    />
  );
};

Custom Styles Example

const customStepStyles = {
  step: { backgroundColor: 'lightblue' },
  circle: { borderColor: 'blue' },
  title: { color: 'darkblue' },
};

const steps = [
  { title: 'Step 1', customStyles: customStepStyles },
  { title: 'Step 2' },
  { title: 'Step 3' },
];

<Stepper steps={steps} customStyles={{ stepper: { backgroundColor: 'lightgray' } }} />

See full example here

API

Props

Prop NameTypeDefault ValueDescription
widthnumberThe width of the step as a percentage of the total width of the stepper.
activeColorstring'#5096FF'The background color of the active step.
completeColorstring'#5096FF'The background color of the completed steps.
defaultColorstring'#E0E0E0'The background color of the inactive steps.
activeTitleColorstring'#000'The text color of the active step title.
completeTitleColorstring'#000'The text color of the completed step titles.
defaultTitleColorstring'#757575'The text color of the inactive step titles.
circleFontColorstring'#FFF'The font color of the step index or icon.
sizenumber32The size of the step circle.
circleFontSizenumber16The font size of the step index or icon.
titleFontSizenumber16The font size of the step title.
circleTopnumber24The top margin for the step circle.
titleTopnumber8The top margin for the step title.
titlestringThe title of the step.
indexnumberThe index of the step.
activeboolfalseIndicates if the step is active.
completedboolfalseIndicates if the step is completed.
firstboolfalseIndicates if the step is the first step.
isLastboolfalseIndicates if the step is the last step.
completeOpacitystringThe opacity of the completed step.
activeOpacitystringThe opacity of the active step.
defaultOpacitystringThe opacity of the inactive step.
completeTitleOpacitystringThe opacity of the completed step title.
activeTitleOpacitystringThe opacity of the active step title.
defaultTitleOpacitystringThe opacity of the inactive step title.
barStylestring'solid'The style of the connecting bar.
defaultBarColorstring'#E0E0E0'The color of the inactive connecting bar.
completeBarColorstringThe color of the completed connecting bar.
defaultBorderColorstringThe border color of the inactive step circle.
completeBorderColorstringThe border color of the completed step circle.
activeBorderColorstringThe border color of the active step circle.
defaultBorderStylestring'solid'The border style of the inactive step circle.
completeBorderStylestringThe border style of the completed step circle.
activeBorderStylestringThe border style of the active step circle.
lineMarginOffsetnumber4The margin offset for the connecting lines.
defaultBorderWidthnumber3The border width of the step circle.
hrefstringThe URL to navigate to when the step is clicked.
onClickfuncThe function to call when the step is clicked.
customStylesobject{}Custom styles to apply to various parts of the step.

Stepper Component

The Stepper component manages and displays a series of Step components.

Props

Prop NameTypeDefault ValueDescription
activeStepnumber0The index of the currently active step.
stepsarrayOfAn array of step objects. Each step object should contain title, icon, href, onClick, and optional customStyles.
shape({
title:
icon:
href:
onClick:
customStyles: object })
disabledStepsarrayOf[]An array of indices representing steps that are disabled.
customStylesobject{}Custom styles to apply to the stepper container and the stepper.

Step Objects

namedescriptiondefaulttype
titleDisplayed text of the step below the numberundefinedstring
iconDisplayed icon of the stepundefinedimage/object
hrefLink to send them to on clickundefinedstring
onClickEvent handler for when the step is clickedundefinedfunction

Author

Sadequl Islam / @sadequlfakir

License

MIT