Stepper
The Stepper component is a versatile tool that allows developers to create a highly customizable step-based interface. It provides a variety of subcomponents that can be tailored to suit different use cases. use-cases.
The many parts of the Stepper component are as follows:
Step
: This is the main component for an individual step. It holds the components that make up the content of the step.StepDescription
: This component is used to provide a brief description of the particular step.StepIcon
: This component is used to display an icon for the step. It's commonly used to indicate the completion of a step.StepIndicator
: This component wraps around the step's status elements, such as the StepIcon and StepNumber.StepNumber
: This component is used to display the numeric value of the step.StepSeparator
: This component is used to visually separate individual steps.StepStatus
: This component is used to switch between different step states, like complete, incomplete, and active. It usually wraps around the StepIcon or StepNumber component.StepTitle
: This component is used to display the title of a particular step.Stepper
: This is the parent component that holds and manages all the Step components. It keeps track of the current active step and can control the orientation and size of the stepper.These components can be imported as follows:
Examples
Using the Stepper Component
In the following example, the steps array holds the different steps for our stepper. For each step, we provide a title and description, which are displayed in the StepTitle and StepDescription components respectively.
We use the useSteps hook to manage the active step, with the index starting at 1. The Stepper component takes the activeStep as a prop to know which step to highlight. Inside the StepIndicator, we use the StepStatus component to render different content based on whether the step is complete, incomplete, or active.
Welcome
Overview
Sign up
Code
Modifying the Stepper Orientation
By default, the stepper component is displayed horizontally. However, you can change its orientation to vertical by passing the orientation prop as 'vertical'. You can also set the height and the gap between steps. The following stepper is almost identical to the first, only this time it is displayed vertically.
Welcome
Overview
Sign up
Code
Adjusting the size
Welcome
Overview
Sign up
Code
Color Variation
Welcome
Overview
Sign up
Code
Adjusting Content
Welcome
Overview
Sign up
Code
Setting Active Step
Welcome
Overview
Sign up
Code
Progress Bar
Below is an example where a Progress component is added. The progress is updated based on the active step, which is managed by useSteps. Note that the progress bar is absolutely positioned within the Box that wraps the Stepper, so it will display underneath the step indicators.
In this example, the 'Second' step will be the active step when the component is first rendered because we're setting the initial index to 1. The progress bar will represent the progress through the steps as the user interacts with the stepper.
Code
Step Summary
In this interactive example, you'll notice the step summary displayed beneath the step group, making it easier to identify the current step even when the labels are not directly visible.
First: Welcome
Code
Did you know?
Creative Idea No. 1
Code
Creative Idea No. 2
Size
Toppings
Buy
Code
Creative Idea No. 3
Choose Size
Choose Toppings
Code
copyright © 2023 IHeartComponents | evanmarie.com
created with love by the I♥️Components team using
Special thanks to Stefan Bohacek / Generative Placeholders.