“Let us
<Step>
into the night and pursue that flighty temptress, adventure.”-- Albus Dumbledore
What is React Albus?
React Albus is a React component library for building declarative multi-step flows (also known as Wizards). You are responsible for writing your own steps and configuring their ordering, but React Albus will maintain the flow-related state for you.
React Albus also allows you to create routed flows, conditionally skip steps in your flow, and create custom elements to suit your needs.
import React from 'react';
import { Wizard, Step, Steps, Navigation } from 'react-albus';
const Simple = () =>
<Wizard>
<Steps>
<Step path="firstStep">
<h1>First Step</h1>
<Navigation
render={({ next }) =>
<button onClick={next}>Next</button>}
/>
</Step>
<Step path="secondStep">
<h1>Second Step</h1>
<Navigation
render={({ next, previous }) =>
<div>
<button onClick={next}>Next</button>
<button onClick={previous}>Previous</button>
</div>}
/>
</Step>
<Step path="thirdStep">
<h1>Third Step</h1>
<Navigation
render={({ previous }) =>
<button onClick={previous}>Previous</button>}
/>
</Step>
</Steps>
</Wizard>;
export default Simple;
To explore more examples, git clone
, npm install
and npm start
.
A function that will be called by Wizard to determine the next step to proceed to.
step
: An object describing the current step with the signature:{ path: string, name: string }
.steps
: An array ofstep
objects in the order they were declared in<Steps>
.push(path)
: A function that can be called with thepath
of the step that you want to proceed to. Calling this function without arguments will proceed to the next step.
If you do not pass an onNext
prop, <Wizard>
will proceed directly to the next step.
CSS classes to be added to the <div>
created by <Wizard>
.
A function that will be used as the render function of <Wizard>
.
wizard
: Thecontext.wizard
object.
Wraps all the content that will be conditionally shown when the step is active.
Unique key for each step.
A name for the step that can later be accessed on context.wizard
.
CSS classes to be added to the <div>
created by <Step>
.
Wraps all of the <Step>
components for your flow. The only direct children of <Steps>
should be <Step>
components.
An object describing the current step with the signature: { path: string, name: string }
. Defining this prop will make <Steps>
a controlled component.
Exposes the Wizard navigation functionality for your components to use. Extends its child's props with context.wizard
and passes context.wizard
to its render prop.
A function that will be used as the render function of <Navigation>
.
wizard
: Thecontext.wizard
object.
A higher order component that spreads context.wizard
across the wrapped component's props.
<Wizard>
adds this object to context with the following properties:
step
(object): Describes the current step with signature:{ path: string, name: string }
.steps
(array): Array ofstep
objects in the order they were declared within<Steps>
.history
(object): The backinghistory
object.next()
(function): Moves to the next step in order.previous()
(function): Moves to the previous step in order.go(n)
(function): Moves n steps in history.push(path)
(function): Moves to the step with proppath
.
Internally, React Albus uses history to maintain the ordering of steps. This makes integrating with React Router (or any other router) as easy as providing Albus with a history
object and a basename
where it is living.
import React from 'react';
import { Route } from 'react-router-dom';
import { Wizard } from 'react-albus';
const RoutedWizard = ({ children }) =>
<Route
render={({ history, match: { url } }) =>
<Wizard history={history} basename={url}>
{children}
</Wizard>}
/>;
export default RoutedWizard;
We welcome Your interest in the American Express Open Source Community on Github. Any Contributor to any Open Source Project managed by the American Express Open Source Community must accept and sign an Agreement indicating agreement to the terms below. Except for the rights granted in this Agreement to American Express and to recipients of software distributed by American Express, You reserve all right, title, and interest, if any, in and to Your Contributions. Please fill out the Agreement.
Any contributions made under this project will be governed by the Apache License 2.0.
This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.