Stepper and its sub components where inspired by 2 community based components.
react-albusfor its wizard style implementation@material-ui/core/StepperFor is vertical stepper
Concepts from both have been implemented but Stepper is heavily based on react-albus
See examples here: https://sjones5-sh.github.io/Stepper/
For use with history. Configures the base path for the Stepper so that routing is preserved.
allows for startWith matching on rout changes
There are 2 modes of using Stepper
- stepper (default)
- wizard
By default Stepper will act as a stepper.
The difference between the modes is that a stepper will keep all Steps in the DOM and will apply classes the content.
This gives presentation control to the implementor to hide / show / style the steps as desired.
See <Step> for more
In wizard mode the Step's children are mounted and unmounted when presented.
A function that will be called by <Stepper> to determine the next step to proceed to.
wizard(object): Thecontext.wizardobject.
If you do not pass an onNext prop, <Wizard> will proceed directly to the next step.
A function that will be used as the render function of <Wizard>.
wizard(object): Thecontext.wizardobject.
<Stepper> provides an object on context with the following properties:
step(object): Describes the current step with structure:{ id: string }.steps(array): Array ofstepobjects in the order they were declared within<Steps>.history(object): The backinghistoryobject.next()(function): Moves to the next step in order.previous()(function): Moves to the previous step in order.go(n)(function): Movesnsteps in history.push(id)(function): Pushes the step with correspondingidonto history.replace(id)(function): Replaces the current step in history with the step with correspondingid.set(id)(function): Move to stepid.
Wraps all of the <Step> components in your journey. The only direct children of <Steps> should be <Step> components.
An object describing the current step with the structure: { id: string }. Defining a step prop will make <Steps> a controlled component.
Controlled
<Stepper
render={({step}) => (
<Steps key={step.id} step={step}>
<Step id={"Step1"} />
...Uncontrolled
<Stepper>
<Steps>
<Step id={"Step1"} />
...Wraps all the content that will be rendered or conditionally shown when the step is active.
Stepper__StepStepper__Step--active: props.activeStepper__Step--complete: props.completeStepper__Step--disabled: props.disabledStepper__Step--first: props.firstStepper__Step--last: props.lastStepper__Step--error: props.error
Unique key for each step.
In addition to id, any additional props added to <Step> will be available on each step object. This can be used to add names, descriptions, or other metadata to each step.
activecompletedisabledfirstlasterror
applies click handler to Step wrapping div
function is called with arguments wizard, props
const onClick = (wizard, {active, complete, ...props}) => {...}Fires when active changes to true
function is called with arguments wizard, props
const onOpen = (wizard, {active, complete, ...props}) => {...}Fires when active changes to false
function is called with arguments wizard, props
const onClose = (wizard, {active, complete, ...props}) => {...}applies className to Step wrapping div
optional render method to custom render instead of declaration
Optional to supply render function to custom render instead of declaration.
Otherwise children works as you would expect.
<Step
id={"Step1"}
complete={completeSteps["Step1"]}
onClick={handleStepSelect}
>
<StepHead>Base 1</StepHead>
<StepContent collapsible>Step 1 Content</StepContent>
</Step>
<Step
id={'Custom-Step-1'}
error={true}
render={({wizard, active, error, ...props}) => active && error ? (
<div {...props}>π±</div>
) : null}
onClick={handleStepSelect}
/>
<Step
id={'Custom-Step-2'}
complete={true}
onClick={handleStepSelect}
>
{({wizard, complete, ...props}) => complete ? (
<div {...props}>
β
<button onClick={wizard.next}>NEXT</button>
</div>
) : null}
</Step>Semantic marker for Content in the <Step>. provides API for conditional hiding and show based on the state of the Step.
Also allows for Tansitions.
Renders the content only when Ancestor <Step> is active.
Defaults to true only if hideOnActive is undefined.
Hides the content only when Ancestor <Step> is active
Renders the content only when Ancestor <Step> is complete
Hides the content only when Ancestor <Step> is complete
Control that overrides any and all hide/show props mentioned above.
Enables a @material-ui/core/Collapse for the TransitionComponent to animate the hide/show
This is the root of the content and should be some kind of transistion component. Default is react-transition-group/CSSTransition unless collapsible is set in which case the default will be @material-ui/core/Collapse.
applied to the TransitionComponent
Any remaining props are applied to the root TransitionComponent. See CSSTransition for more.
<StepContent showOnActive>πββοΈ</StepContent>
<StepContent hideOnActive>π»</StepContent>
<StepContent hideOnComplete>π</StepContent>
<StepContent showOnComplete>β
</StepContent>
<StepContent showOnComplete hideOnActive>β
π»</StepContent>
<StepContent show={step.error}>Error content</StepContent>
<StepContent collapsible>Tall content</StepContent>Semantic marker for Header content in the <Step>. provides API for conditional hiding and show based on the state of the Step.
Also allows for Tansitions. Inherits from <StepContent> but is always presented by default.
<StepHead>this content will always show</StepHead>
<StepHead showOnActive>πββοΈ</StepHead>
<StepHead hideOnActive>π»</StepHead>
<StepHead hideOnComplete>π</StepHead>
<StepHead showOnComplete>β
</StepHead>
<StepHead showOnComplete hideOnActive>β
π»</StepHead>
<StepHead show={step.error}>Error content</StepHead>A component that provides a render function providing context.wizard as argument.
Useful for rendering navigation components like progress bars, next/prev buttons, or breadcrumbs.
<WithWizard
render={(wizard) => (
<>
{wizard.steps.map(step => (
<span onClick={() => wizard.set(step.id)}>{step.id}</span>
)}
<ProgressBar
value={wizard.steps.filter(step => step.complete).length / wizard.steps.length} />
<button onClick={wizard.previous}>Prev</button>
<button onClick={wizard.next}>Next</button>
</>
)} />A higher order component that adds context.wizard as a wizard prop on the wrapped component.