A set of steps the user has to go through sequentially.
You should have the chayns-components
package installed. If that is not the
case already, run
yarn add chayns-components
or
npm i chayns-components
After the chayns-components
package is installed, you can import the component
and use it with React:
import React from 'react'
import { SetupWizard } from 'chayns-components';
// ...
<SetupWizard {...} />
The setup wizard exposes several methods on its reference to control its flow:
nextStep()
navigates to the next stepstepComplete(isComplete, stepIndex = currentStep)
marks a step as complete/incompleteresetToStep(stepIndex)
resets the wizard up until a specific indexstepEnabled(isEnabled, stepIndex)
enables or disables a specific stepstepRequired(isRequired, stepIndex)
marks a specific step as required or optional
You can access them in any child components by using the
withSetupWizardContext
higher-order component:
const FirstStep = withSetupWizardContext(
({ nextStep, stepComplete /* ... */ }) => {
// ...
}
);
The SetupWizard
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
children | ReactNode |
||
ready | function |
||
notComplete | function |
||
className | string |
||
style | { [key: string]: string | number } |
||
contentStyle | { [key: string]: string | number } |
||
title | string |
||
description | ReactNode |
||
numberOfSteps | number |
||
allRequiredStepsCompleted | function |
||
initialStep | number |
0 |
|
disableShowStep | boolean |
false |
|
operationMode | enum |
SetupWizard.operationMode.DEFAULT |
children?: ReactNode
An array of SetupWizardItem
components.
ready?: function
A callback that is invoked after nextStep
is called when the last step is
active and all required steps are completed.
notComplete?: function
A callback that is invoked after nextStep
is called but some required steps
are not completed.
className?: string
A classname string that will be applied to the container element.
style?: { [key: string]: string | number }
A React style object that will be applied to the container element.
contentStyle?: { [key: string]: string | number }
A React style object that will be applied to the content elements.
title?: string
The title of the wizard.
description?: ReactNode
The description of the wizard. Can be a string
or a ReactNode
.
numberOfSteps?: number
The number of steps in the wizard.
allRequiredStepsCompleted?: function
A callback that is invoked when all required steps have been completed.
initialStep?: number
The initial step of the wizard.
disableShowStep?: boolean
Removes the number that is displayed in front of the title.
operationMode?: enum
Specifies the mode of the wizard. 0
is the regular behavior, 1
means that
all steps except the current one will be disabled and the user cannot manually
navigate between steps.