Stepper
React Bootstrap 5 Stepper / Wizard component
Responsive stepper built with Bootstrap 5. Form wizard, vertical stepper, multi step form validation, optional step, mobile stepper & more.
Stepper is a component that displays content as a process with defined by user milestones. This is a great solution for a variety of registration forms, where you don't want to scare the user with lots of fields and questions.
In this documentation, you can find examples of form wizard, vertical stepper, horizontal stepper, multi step form, mobile stepper, validation & more.
Note: Read the API tab to find all available options and advanced customization
Basic example
You can automatically initialize the stepper component using
MDBStepper
.
-
step1Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
-
step2
-
step3
Change steps using external elements
To go to the next or previous step, you can use the reference to the buttons.
-
step1Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
-
step2
-
step3
Linear stepper
If you want to use basic validation before proceeding to the next step you can set
linear
property.
No editable stepper
You can set noEditable
property to prevent you from editing the
completed step again.
-
step1
-
step2
-
step3
Vertical stepper
Set type='vertical'
to use the vertical view.
-
step1Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
-
step2Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultriciesUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
step3Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Mobile stepper
Set type='mobile'
to use mobile view.
-
step1Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
-
step2
-
step3
Mobile stepper progress bar
if the stepper contains more than 4 steps, the progress bar will be displayed by default
instead of dots. You can edit the step limit with the
mobileProgress
property.
Custom icons
if you want to use an icon instead of a step number you can do it by setting
MDBStepperHead icon
property.
-
step1
-
step2
-
step3
Form wizard
An example of so-called "Form wizard" with multiple inputs on each step.
Toggle to vertical or mobile on smaller screens
Change the stepper mode depending on window width.
-
step1
-
step2
-
step3
Events
Stepper emits events after successful step validation, after failed step validation, and before changing to another step. Check the browser console and try to change the step to see the result.
-
step1
-
step2
-
step3
Add custom validation
You can use the customValidation
method with MDBStepperStep
component to use your own validation.
Stepper - API
Import
Properties
MDBStepper
Name | Type | Default | Description | Example |
---|---|---|---|---|
defaultStep
|
number | 1 |
Change default step of the stepper. |
<MDBStepper defaultStep={3} />
|
disableHeadSteps
|
boolean | false |
Disable stepper head onClick change. |
<MDBStepper disableHeadSteps />
|
externalNext
|
React.MutableRefObject | null |
Reference to the external element, to change the stepper step to the next. |
<MDBStepper externalNext={nextRef} />
|
externalPrev
|
React.MutableRefObject | null |
Reference to the external element, to change the stepper step to the previous. |
<MDBStepper externalPrev={prevRef} />
|
linear
|
boolean | false |
Set to true to use the linear stepper |
<MDBStepper linear />
|
mobileOfLabel
|
React.ReactNode | 'of' |
Set custom of value in the mobile stepper head. |
<MDBStepper mobileOfLabel='at' />
|
mobileStepLabel
|
React.ReactNode | 'step' |
Set custom step value in the mobile stepper head. |
<MDBStepper mobileStepLabel='element' />
|
mobileBackLabel
|
React.ReactNode | 'BACK' |
Set custom text for BACK button. |
<MDBStepper mobileBackLabel='PREV' />
|
mobileNextLabel
|
React.ReactNode | 'NEXT' |
Set custom text for NEXT button. |
<MDBStepper mobileNextLabel='NXT' />
|
mobileProgress
|
boolean | false |
Enable mobile progress stepper. |
<MDBStepper type='mobile' mobileProgress />
|
noEditable
|
boolean | false |
Set to true to block editing of the completed step. |
<MDBStepper noEditable />
|
type
|
'horizontal' | 'vertical' | 'mobile' | 'horizontal' |
Set the stepper view |
<MDBStepper type='vertical' />
|
MDBStepperStep
Name | Type | Default | Description | Example |
---|---|---|---|---|
contentClassName
|
string | '' |
Add custom classes to content element. |
<MDBStepperStep contentClassName="class" />
|
contentStyle
|
React.CSSProperties | - |
Add custom styles to content element. |
<MDBStepperStep contentStyle={customStyles} />
|
itemId
|
number | - |
Set the step unique id. |
<MDBStepperStep itemId={1} />
|
headClassName
|
string | '' |
Add custom classes to head element. |
<MDBStepperStep headClassName="class" />
|
headStyle
|
React.CSSProperties | - |
Add custom styles to head element. |
<MDBStepperStep headStyle={customStyles} />
|
headIcon
|
React.ReactNode | '0' |
Set step head icon. |
<MDBStepperStep headIcon='6' />
|
headText
|
React.ReactNode | 'none' |
Set step head text. |
<MDBStepperStep headText='step element' />
|
MDBStepperForm
For MDBStepperForm
propeties check the
MDBValidation properties.
Methods
MDBStepperStep
Name | Type | Description |
---|---|---|
customValidation
|
(input: HTMLInputElement) => boolean | Apply custom validation to the step. |
Events
MDBStepper
Name | Type | Description |
---|---|---|
onChange
|
(id: number) => void | Event emitted before the step change. |
onInvalid
|
(id: number) => void | Event emitted after unsuccessful step validation. |
onValid
|
(id: number) => void | Event emitted after successful step validation. |
CSS variables
As part of MDB’s evolving CSS variables approach, stepper now use local CSS variables on
.stepper
for enhanced real-time customization. Values for the CSS variables are
set via Sass, so Sass customization is still supported, too.