Stepper
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
*
*
UMD autoinits are enabled
by default. This means that you don't need to initialize
the component manually. However if you are using MDBootstrap ES format then you should pass
the required components to the initMDB
method.
Basic example
You can automatically initialize the stepper component using
data-mdb-stepper-init
attribute.
-
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 nextStep
and
prevStep
methods. You can also choose a specific step using the
changeStep
method by entering the step index.
-
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 advancing to the next step you can set
data-mdb-stepper-linear="true"
No editable stepper
You can set data-mdb-stepper-no-editable="true"
to prevent editing a completed step.
-
step1
-
step2
-
step3
Vertical stepper
Set data-mdb-stepper-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 ultricies.
-
step3Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
Mobile stepper
Set data-mdb-stepper-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
stepper-mobile-bar-breakpoint
attribute.
Stepper with gesture support
Adding Touch Swipe utils to the stepper enables changing the stepper step using gestures.
-
step1Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
-
step2
-
step3
Optional step
You can mark a step as optional by adding
data-mdb-stepper-optional="true"
to it.
-
step1Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
-
step2
-
step3
Custom icons
if you want to use an icon instead of a step number you can do it by placing it inside
<span class="stepper-head-icon"></span>
-
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
If you want to change the view from horizontal to vertical or mobile with smaller screens you
can use the
data-mdb-stepper-vertical-breakpoint
and
data-mdb-stepper-mobile-breakpoint
attribute specifying the number of pixels at
which the stepper should change to vertical or mobile. You can resize the browser window to
test it.
-
step1
-
step2
-
step3
Events
Stepper emits events after successful step validation, failed step validation, before and after 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 stepChange.mdb.stepper
event to use your own validation.
Stepper - API
Import
Importing components depends on how your application works. If you intend to use the MDBootstrap ES
format, you must
first import the component and then initialize it with the initMDB
method. If you are going to use the UMD
format,
just import the mdb-ui-kit
package.
Usage
Via data attributes
Using the Stepper component doesn't require any additional JavaScript code - simply add
data-mdb-stepper-init
attribute to
.stepper
and use other data attributes to set all options.
For ES
format, you must first import and call the initMDB
method.
Via JavaScript
Via jQuery
Note: By default, MDB does not include jQuery and you have to add it to the project on your own.
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to
data-mdb-
, as in data-mdb-stepper-type="horizontal"
.
Name | Type | Default | Description |
---|---|---|---|
animations
|
Boolean | true |
Set to false to turn off the animations displayed when step changes
|
stepperType
|
String | 'horizontal' |
Sets stepper view. Available types are: horizontal ,
vertical and mobile
|
stepperLinear
|
Boolean | false |
Set to true to use the linear stepper |
stepperNoEditable
|
Boolean | false |
Set to true to block editing of the completed step |
stepperHeadClick
|
Boolean | true |
Set to false to block the possibility of changing a step by clicking on
another step
|
stepperActive
|
String | '' |
Sets a custom active class |
stepperCompleted
|
String | '' |
Sets a custom completed class |
stepperInvalid
|
String | '' |
Sets a custom invalid class |
stepperDisabled
|
String | '' |
Sets a custom disabled class |
stepperOptional
|
Boolean | false |
Sets a optional step. |
stepperVerticalBreakpoint
|
Number | 0 |
Sets the resolution below which the stepper will switch to vertical |
stepperMobileBreakpoint
|
Number | 0 |
Sets the resolution below which the stepper will switch to mobile |
stepperMobileBarBreakpoint
|
Number | 4 |
Sets the step limit after which the progress bar will appear in the mobile view instead of the dots |
stepperMobileNextBtn
|
String | 'NEXT' |
Sets custom text for the NEXT button |
stepperMobileBackBtn
|
String | 'BACK' |
Sets custom text for the BACK button |
stepperMobileStepTxt
|
String | 'step' |
Sets custom step value in the mobile stepper head |
stepperMobileOfTxt
|
String | 'of' |
Sets custom of value in the mobile stepper head |
Methods
Name | Description | Example |
---|---|---|
dispose
|
Removes mdb.Stepper instance. |
stepper.dispose()
|
changeStep
|
Switch to the step given as the parameter |
stepper.changeStep()
|
getInstance
|
Static method which allows you to get the stepper instance associated to a DOM element. |
Stepper.getInstance(myStepperEl)
|
getOrCreateInstance
|
Static method which returns the stepper instance associated to a DOM element or create a new one in case it wasn't initialized. |
Stepper.getOrCreateInstance(myStepperEl)
|
nextStep
|
Switch to the next step |
stepper.nextStep()
|
prevStep
|
Switch to the previous step |
stepper.prevStep()
|
resizeStepper
|
Reset the height and view of the stepper |
stepper.resizeStepper()
|
Events
Name | Description |
---|---|
stepChange.mdb.stepper
|
This event is emitted before the step change takes place. By using e.preventDefault() you
can implement custom validation.
Information about the current and next steps can be accessed through the following properties of the
emitted event: e.currentStep and e.nextStep . |
stepChanged.mdb.stepper
|
This event is emitted after the step change takes place. Information about the current and previous
steps can be accessed through the following properties of the emitted event: e.currentStep
and e.prevStep . |
stepValid.mdb.stepper
|
This event is emitted after successful step validation. Information about the current and next steps can be accessed through the following properties of the
emitted event: e.currentStep and e.nextStep . |
stepInvalid.mdb.stepper
|
This event is emitted after unsuccessful step validation. Information about the current and next steps can be accessed through the following properties of the
emitted event: e.currentStep and e.nextStep . |
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.