2.0.3 • Published 4 months ago

react-native-progress-steps v2.0.3

Weekly downloads
771
License
MIT
Repository
github
Last release
4 months ago

npm.io npm.io PRs Welcome

React Native Progress Steps

A simple and fully customizable React Native component that implements a progress stepper UI.

  • Each steps content is displayed inside of a customizable ScrollView.
  • Customizable buttons are displayed at the bottom of the component to move between steps.

✨ What's New in v2.0

  • 🎯 Full TypeScript Support - Complete type definitions for an enhanced development experience
  • 🔄 Modern Component Architecture - Refactored to use functional components and React hooks
  • 🎨 Major UI/UX Improvements
    • Enhanced responsiveness and layout
    • Modernized styling with new step icons, default colors, and button design
    • Improved performance
    • Better readability
  • 💫 Smooth Step Transitions - Added subtle animations when changing between steps
  • 🛠️ Enhanced Customization - Streamlined props with new customization options and removal of legacy features
  • ⛔️ Breaking Changes - Some props have been removed and renamed. See the Migration Guide for more details.

Example

examples/example.jsx

Installation

npm i react-native-progress-steps

Usage

import { ProgressSteps, ProgressStep } from 'react-native-progress-steps';

Simply place a <ProgressStep /> tag for each desired step within the <ProgressSteps /> wrapper.

<View style={{flex: 1}}>
    <ProgressSteps>
        <ProgressStep label="First Step">
            <View style={{ alignItems: 'center' }}>
                <Text>This is the content within step 1!</Text>
            </View>
        </ProgressStep>
        <ProgressStep label="Second Step">
            <View style={{ alignItems: 'center' }}>
                <Text>This is the content within step 2!</Text>
            </View>
        </ProgressStep>
        <ProgressStep label="Third Step">
            <View style={{ alignItems: 'center' }}>
                <Text>This is the content within step 3!</Text>
            </View>
        </ProgressStep>
    </ProgressSteps>
</View>

Button Styling Usage

Navigation buttons are customizable using the various props provided to the ProgressStep component. See the Progress Step Component section for more details.

Simple example to set a specific button text:

return (
    <View style={{flex: 1}}>
        <ProgressSteps>
            <ProgressStep label="First Step" buttonNextText="Next Step" buttonPreviousText="Previous Step">
                <View style={{ alignItems: 'center' }}>
                    <Text>This is the content within step 1!</Text>
                </View>
            </ProgressStep>
            <ProgressStep label="Second Step" buttonNextText="Next Step" buttonPreviousText="Previous Step">
                <View style={{ alignItems: 'center' }}>
                    <Text>This is the content within step 2!</Text>
                </View>
            </ProgressStep>
        </ProgressSteps>
    </View>
)

Hiding the Button Row

To hide the button row, set the removeBtnRow prop to true. The current step can be changed without the buttons by updating and managing the activeStep prop on the <ProgressSteps /> component.

const [activeStep, setActiveStep] = useState(0);

<ProgressSteps activeStep={activeStep}>
    <ProgressStep label="First Step" removeBtnRow>
        <View style={{ alignItems: 'center' }}>
            <Text>This is the content within step 1!</Text>
        </View>
    </ProgressStep>
</ProgressSteps>

Current Step Error and Validation Handling

The errors prop should be used if there's a need for validation and error handling when clicking the next button. If you would like to prevent the next step from being rendered, set the errors prop to true. By default, it will be false.

Example usage of validation check:

const [isValid, setIsValid] = useState(false);
const [errors, setErrors] = useState(false);

const onNextStep = () => {
    if (!isValid) {
      setErrors(true);
    } else {
      setErrors(false);
    }
};

return (
    <View style={{ flex: 1 }}>
        <ProgressSteps>
          <ProgressStep label="First Step" onNext={onNextStep} errors={errors}>
            <View style={{ alignItems: 'center' }}>
              <Text>This is the content within step 1!</Text>
            </View>
          </ProgressStep>
          <ProgressStep label="Second Step">
            <View style={{ alignItems: 'center' }}>
              <Text>This is the content within step 2!</Text>
            </View>
          </ProgressStep>
        </ProgressSteps>
      </View>
);

Documentation

Progress Steps Component

NameDescriptionDefaultType
borderWidthWidth of the progress bar between steps2Number
activeStepIconBorderColorOutside border color for the active step#2D2D2DString
progressBarColorColor of the default progress bar#EBEBE4String
completedProgressBarColorColor of the completed progress bar#2D2D2DString
activeStepIconColorColor of the active step icontransparentString
completedStepIconColorColor of the completed step icon#2D2D2DString
disabledStepIconColorColor of the disabled step icon#EBEBE4String
labelFontFamilyFont family for the step icon labelSystem defaultString
labelColorColor of the default label#D3D3D3String
labelFontSizeFont size for the step icon label14Number
activeLabelColorColor of the active label#2D2D2DString
activeLabelFontSizeOptional font size for the active step icon label14Number
completedLabelColorColor of the completed label#2D2D2DString
activeStepNumColorColor of the active step number#2D2D2DString
completedStepNumColorColor of the completed step number#2D2D2DString
disabledStepNumColorColor of the disabled step number#FFFFFFString
completedCheckColorColor of the completed step checkmark#FFFFFFString
activeStepManually specify the active step0Number
isCompleteSet all Steps to active statefalseBoolean
topOffsetSet progress bar top offset60Number
marginBottomSet progress bar bottom margin30Number

Progress Step Component

NameDescriptionDefaultType
labelTitle of the current step to be displayedundefinedString
onNextFunction called when the next step button is pressedundefinedFunc
onPreviousFunction called when the previous step button is pressedundefinedFunc
onSubmitFunction called when the submit step button is pressedundefinedFunc
scrollViewPropsObject to provide props to ScrollView componentundefinedObject
scrollableThe content of the Progress Step should be scrollabletrueBoolean
viewPropsObject to provide props to view component if scrollable is falseundefinedObject
errorsUsed to assist with current step validation. If true, the next step won't be renderedfalseBoolean
removeBtnRowUsed to render the progress step without the button rowfalseBoolean
buttonNextTextText to display inside the next buttonNextString
buttonPreviousTextText to display inside the previous buttonPreviousString
buttonFinishTextText to display inside the button on the last stepSubmitString
buttonNextDisabledValue to disable/enable next buttonfalseBoolean
buttonPreviousDisabledValue to disable/enable previous buttonfalseBoolean
buttonFinishDisabledValue to disable/enable finish buttonfalseBoolean
buttonTopOffsetSet button row top offset12Number
buttonBottomOffsetSet button row bottom offset20Number
buttonHorizontalOffsetSet button row horizontal offset30Number
buttonFillColorBackground color for the next/finish buttons#2D2D2DString
buttonBorderColorBorder color for the previous button#2D2D2DString
buttonNextTextColorText color for the next button#FFFFFFString
buttonPreviousTextColorText color for the previous button#2D2D2DString
buttonFinishTextColorText color for the finish button#FFFFFFString
buttonDisabledColorBackground color for disabled buttons#CDCDCDString
buttonDisabledTextColorText color for disabled buttons#FFFFFFString

Migration Guide (v1 to v2)

Breaking Changes

Renamed Props

The following props have been renamed for better clarity and consistency:

Old Prop NameNew Prop NameComponent
nextBtnTextbuttonNextTextProgressStep
previousBtnTextbuttonPreviousTextProgressStep
finishBtnTextbuttonFinishTextProgressStep
nextBtnDisabledbuttonNextDisabledProgressStep
previousBtnDisabledbuttonPreviousDisabledProgressStep

Removed Props

The following props have been removed in favor of the new styling system:

Removed PropAlternative
nextBtnStyleUse buttonFillColor and other button styling props
nextBtnTextStyleUse buttonNextTextColor instead
previousBtnStyleUse buttonBorderColor and other button styling props
previousBtnTextStyleUse buttonPreviousTextColor instead
finishBtnStyleUse buttonFillColor and other button styling props
finishBtnTextStyleUse buttonFinishTextColor instead
borderStyleNo longer supported

New Button Styling System

Instead of using style objects, the new version provides specific props for common button customizations:

// Old way
<ProgressStep
  nextBtnStyle={{ backgroundColor: '#2D2D2D' }}
  nextBtnTextStyle={{ color: '#FFFFFF' }}
>
  {/* content */}
</ProgressStep>

// New way
<ProgressStep
  buttonFillColor="#2D2D2D"
  buttonNextTextColor="#FFFFFF"
>
  {/* content */}
</ProgressStep>

See the Progress Step Component section for all available button styling props.

Contributing

Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.

Working on your first Pull Request? You can learn how from GitHub's First Contributions guide or their How to Contribute to Open Source guide.

Author

Colby Miller | https://colbymillerdev.com

License

MIT

2.0.3

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.9

5 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago