这是一个简单且完全可自定义的 React Native 组件,实现了进度步进器 UI。
A simple and fully customizable React Native component that implements a progress stepper UI.
examples/example.jsx
npm i react-native-progress-stepsimport { ProgressSteps, ProgressStep } from 'react-native-progress-steps';Simply place a tag for each desired step within the wrapper.
This is the content within step 1!
This is the content within step 2!
This is the content within step 3!
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 (
This is the content within step 1!
This is the content within step 2!
)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 `` component.
const [activeStep, setActiveStep] = useState(0);
This is the content within step 1!
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 (
This is the content within step 1!
This is the content within step 2!
);| Name | Description | Default | Type |
|---|---|---|---|
| borderWidth | Width of the progress bar between steps | 2 | Number |
| activeStepIconBorderColor | Outside border color for the active step | #2D2D2D | String |
| progressBarColor | Color of the default progress bar | #EBEBE4 | String |
| completedProgressBarColor | Color of the completed progress bar | #2D2D2D | String |
| activeStepIconColor | Color of the active step icon | transparent | String |
| completedStepIconColor | Color of the completed step icon | #2D2D2D | String |
| disabledStepIconColor | Color of the disabled step icon | #EBEBE4 | String |
| labelFontFamily | Font family for the step icon label | System default | String |
| labelColor | Color of the default label | #D3D3D3 | String |
| labelFontSize | Font size for the step icon label | 14 | Number |
| activeLabelColor | Color of the active label | #2D2D2D | String |
| activeLabelFontSize | Optional font size for the active step icon label | 14 | Number |
| completedLabelColor | Color of the completed label | #2D2D2D | String |
| activeStepNumColor | Color of the active step number | #2D2D2D | String |
| completedStepNumColor | Color of the completed step number | #2D2D2D | String |
| disabledStepNumColor | Color of the disabled step number | #FFFFFF | String |
| completedCheckColor | Color of the completed step checkmark | #FFFFFF | String |
| activeStep | Manually specify the active step | 0 | Number |
| isComplete | Set all Steps to active state | false | Boolean |
| topOffset | Set progress bar top offset | 60 | Number |
| marginBottom | Set progress bar bottom margin | 30 | Number |
| Name | Description | Default | Type |
|---|---|---|---|
| label | Title of the current step to be displayed | undefined | String |
| onNext | Function called when the next step button is pressed | undefined | Func |
| onPrevious | Function called when the previous step button is pressed | undefined | Func |
| onSubmit | Function called when the submit step button is pressed | undefined | Func |
| scrollViewProps | Object to provide props to ScrollView component | undefined | Object |
| scrollable | The content of the Progress Step should be scrollable | true | Boolean |
| viewProps | Object to provide props to view component if scrollable is false | undefined | Object |
| errors | Used to assist with current step validation. If true, the next step won't be rendered | false | Boolean |
| removeBtnRow | Used to render the progress step without the button row | false | Boolean |
| buttonNextText | Text to display inside the next button | Next | String |
| buttonPreviousText | Text to display inside the previous button | Previous | String |
| buttonFinishText | Text to display inside the button on the last step | Submit | String |
| buttonNextDisabled | Value to disable/enable next button | false | Boolean |
| buttonPreviousDisabled | Value to disable/enable previous button | false | Boolean |
| buttonFinishDisabled | Value to disable/enable finish button | false | Boolean |
| buttonTopOffset | Set button row top offset | 12 | Number |
| buttonBottomOffset | Set button row bottom offset | 20 | Number |
| buttonHorizontalOffset | Set button row horizontal offset | 30 | Number |
| buttonFillColor | Background color for the next/finish buttons | #2D2D2D | String |
| buttonBorderColor | Border color for the previous button | #2D2D2D | String |
| buttonNextTextColor | Text color for the next button | #FFFFFF | String |
| buttonPreviousTextColor | Text color for the previous button | #2D2D2D | String |
| buttonFinishTextColor | Text color for the finish button | #FFFFFF | String |
| buttonDisabledColor | Background color for disabled buttons | #CDCDCD | String |
| buttonDisabledTextColor | Text color for disabled buttons | #FFFFFF | String |
The following props have been renamed for better clarity and consistency:
| Old Prop Name | New Prop Name | Component |
|---|---|---|
| nextBtnText | buttonNextText | ProgressStep |
| previousBtnText | buttonPreviousText | ProgressStep |
| finishBtnText | buttonFinishText | ProgressStep |
| nextBtnDisabled | buttonNextDisabled | ProgressStep |
| previousBtnDisabled | buttonPreviousDisabled | ProgressStep |
The following props have been removed in favor of the new styling system:
| Removed Prop | Alternative |
|---|---|
| nextBtnStyle | Use buttonFillColor and other button styling props |
| nextBtnTextStyle | Use buttonNextTextColor instead |
| previousBtnStyle | Use buttonBorderColor and other button styling props |
| previousBtnTextStyle | Use buttonPreviousTextColor instead |
| finishBtnStyle | Use buttonFillColor and other button styling props |
| finishBtnTextStyle | Use buttonFinishTextColor instead |
| borderStyle | No longer supported |
Instead of using style objects, the new version provides specific props for common button customizations:
// Old way
{/* content */}
// New way
{/* content */}
See the Progress Step Component section for all available button styling props.
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.
Colby Miller | https://colbymillerdev.com
暂无开放 Issues,或尚未同步最近议题。