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


Basic example

You can automatically initialize the stepper component using data-mdb-stepper="stepper"

  • 1 step1
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
  • 2 step2
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
        
            
            <ul class="stepper" data-mdb-stepper="stepper">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
                  incididunt ut labore et dolore magna aliqua
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
                  ex ea commodo consequat
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
            </ul>
          
        
    

Change steps using external elements

To go to the next or previous step, you can use the nextStep and previousStep methods. You can also choose a specific step using the changeStep method by entering the step index

  • 1 step1
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
  • 2 step2
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
        
            
            <div class="mb-3">
              <button id="prev-step" class="btn btn-primary">prev</button>
              <button id="step-1" class="btn btn-primary">step1</button>
              <button id="step-2" class="btn btn-primary">step2</button>
              <button id="step-3" class="btn btn-primary">step3</button>
              <button id="next-step" class="btn btn-primary">next</button>
            </div>
            <div>
              <ul class="stepper" id="stepper-buttons">
                <li class="stepper-step stepper-active">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">1</span>
                    <span class="stepper-head-text">step1</span>
                  </div>
                  <div class="stepper-content py-3">
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
                    incididunt ut labore et dolore magna aliqua
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">2</span>
                    <span class="stepper-head-text">step2</span>
                  </div>
                  <div class="stepper-content py-3">
                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
                    ex ea commodo consequat
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">3</span>
                    <span class="stepper-head-text">step3</span>
                  </div>
                  <div class="stepper-content py-3">
                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                    fugiat nulla pariatur
                  </div>
                </li>
              </ul>
            </div>
          
        
    
        
            
            const stepper = new mdb.Stepper(document.getElementById('stepper-buttons'));

            document.getElementById('next-step').addEventListener('click', () => {
              stepper.nextStep();
            });

            document.getElementById('prev-step').addEventListener('click', () => {
              stepper.previousStep();
            });

            document.getElementById('step-1').addEventListener('click', () => {
              stepper.changeStep(0);
            });

            document.getElementById('step-2').addEventListener('click', () => {
              stepper.changeStep(1);
            });

            document.getElementById('step-3').addEventListener('click', () => {
              stepper.changeStep(2);
            });
          
        
    

Linear stepper

If you want to use basic validation before proceeding to the next step you can set data-mdb-stepper-linear="true"

  • 1 step1
    invalid
  • 2 step2
    invalid
  • 3 step3
    invalid
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-linear="true">
              <form class="needs-validation stepper-form" novalidate>
                <li class="stepper-step stepper-active">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">1</span>
                    <span class="stepper-head-text">step1</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="text" id="linear-stepper-input-1" class="form-control" required />
                      <label class="form-label" for="linear-stepper-input-1">step 1</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">2</span>
                    <span class="stepper-head-text">step2</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="text" id="linear-stepper-input-2" class="form-control" required />
                      <label class="form-label" for="linear-stepper-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">3</span>
                    <span class="stepper-head-text">step3</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="text" id="linear-stepper-input-3" class="form-control" required />
                      <label class="form-label" for="linear-stepper-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                    <button class="btn btn-primary" type="submit">Submit</button>
                  </div>
                </li>
              </form>
            </ul>
          
        
    

No editable stepper

You can set data-mdb-stepper-no-editable="true" to prevent you from editing the completed step again

  • 1 step1
    invalid
  • 2 step2
    invalid
  • 3 step3
    invalid
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-no-editable="false">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="no-editable-stepper-input-1" class="form-control" required />
                      <label class="form-label" for="no-editable-stepper-input-1">step 1</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="no-editable-stepper-input-2" class="form-control" required />
                      <label class="form-label" for="no-editable-stepper-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="no-editable-stepper-input-3" class="form-control" required />
                      <label class="form-label" for="no-editable-stepper-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
            </ul>
          
        
    

Vertical stepper

Set data-mdb-stepper-type="vertical" to use the vertical view

  • 1 step1
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
  • 2 step2
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
  • 3 step3
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-type="vertical">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
            </ul>
          
        
    

Mobile stepper

Set data-mdb-stepper-type="mobile" to use mobile view

  • 1 step1
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
  • 2 step2
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-type="mobile">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
                  incididunt ut labore et dolore magna aliqua
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
                  ex ea commodo consequat
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
            </ul>
          
        
    

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

  • 1 step1
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
  • 2 step2
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
  • 3 step3
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-type="mobile">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
                  incididunt ut labore et dolore magna aliqua
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
                  ex ea commodo consequat
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                  fugiat nulla pariatur
                </div>
              </li>
            </ul>
          
        
    

Optional step

You can mark a step as optional by adding data-mdb-stepper-optional="true" to it

  • 1 step1
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
  • 2 step2
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
  • 3 step3
    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
        
            
            <ul class="stepper" data-mdb-stepper="stepper">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
              <li class="stepper-step" data-mdb-stepper-optional="true">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <span>
                    Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque
                    dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies.
                  </span>
                </div>
              </li>
            </ul>
          
        
    

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-text"></span>

  • step1
    invalid
  • step2
    invalid
  • step3
    invalid
        
            
            <ul class="stepper" data-mdb-stepper="stepper">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <i class="fas fa-user"></i>
                  </span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="custom-icon-input-1" class="form-control" required />
                      <label class="form-label" for="custom-icon-input-1">step 1</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <i class="fas fa-envelope"></i>
                  </span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="custom-icon-input-2" class="form-control" required />
                      <label class="form-label" for="custom-icon-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  </span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="custom-icon-input-3" class="form-control" required />
                      <label class="form-label" for="custom-icon-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
            </ul>
          
        
    

Form wizard

An example of so-called "Form wizard" with multiple inputs on each step.

  • 1 step1
    invalid
    invalid
  • 2 step2
    invalid
    invalid
    invalid
    invalid
  • 3 step3
        
            
            <!-- Form wizrd -->
            <div>
              <!-- Steps -->
              <ul class="stepper" id="stepper-form-example" data-mdb-stepper-linear="true">
                <form class="needs-validation stepper-form">
                  <!-- First step -->
                  <li class="stepper-step stepper-active">
                    <div class="stepper-head">
                      <span class="stepper-head-icon">1</span>
                      <span class="stepper-head-text">step1</span>
                    </div>
                    <div class="stepper-content py-3">
                      <div class="form-outline mb-4">
                        <input type="text" id="stepper-form-first-name" class="form-control" required/>
                        <label class="form-label" for="stepper-form-first-name">First name<small class="text-muted">(required)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>

                      <div class="form-outline mb-4">
                        <input type="text" id="stepper-form-last-name" class="form-control" required/>
                        <label class="form-label" for="stepper-form-last-name">Last name<small class="text-muted">(required)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>

                      <div class="form-outline mb-4">
                        <input type="text" id="stepper-form-last-name" class="form-control" />
                        <label class="form-label" for="stepper-form-last-name">Nickname<small class="text-muted">(optional)</small></label>
                      </div>
                    </div>
                  </li>
                  <!-- First step -->

                  <!-- Second step -->
                  <li class="stepper-step">
                    <div class="stepper-head">
                      <span class="stepper-head-icon">2</span>
                      <span class="stepper-head-text">step2</span>
                    </div>
                    <div class="stepper-content py-3">
                      <div class="form-outline mb-4">
                        <input type="text" id="form6Example3" class="form-control" required />
                        <label class="form-label" for="form6Example3">Company name<small class="text-muted">(required)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>

                      <div class="form-outline mb-4">
                        <input type="text" id="form6Example4" class="form-control" required />
                        <label class="form-label" for="form6Example4">Address<small class="text-muted">(required)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>

                      <div class="form-outline mb-4">
                        <input type="email" id="form6Example5" class="form-control" required />
                        <label class="form-label" for="form6Example5">Email<small class="text-muted">(required)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>

                      <div class="form-outline mb-4">
                        <input type="number" id="form6Example6" class="form-control" />
                        <label class="form-label" for="form6Example6">Phone<small class="text-muted">(optional)</small></label>
                        <div class="invalid-feedback">invalid</div>
                      </div>
                    </div>
                  </li>
                  <!-- Second step -->

                  <!-- Third step -->
                  <li class="stepper-step">
                    <div class="stepper-head">
                      <span class="stepper-head-icon">3</span>
                      <span class="stepper-head-text">step3</span>
                    </div>
                    <div class="stepper-content py-3">
                      <div class="form-outline mb-4">
                        <textarea class="form-control" id="form6Example7" rows="4"></textarea>
                        <label class="form-label" for="form6Example7">Additional information</label>
                      </div>

                      <div class="form-check d-flex justify-content-center mb-4">
                        <input class="form-check-input me-2" type="checkbox" value="" id="form6Example8" checked/>
                        <label class="form-check-label" for="form6Example8">Create an account?</label>
                      </div>

                      <button type="submit" class="btn btn-success btn-block mb-4">Place order</button>
                    </div>
                  </li>
                  <!-- Third step -->
                </form>
              </ul>
              <!-- Steps -->

              <!-- Buttons -->
              <div class="d-flex justify-content-center px-3">
                <button id="form-example-prev-step" class="btn btn-primary w-100 me-2">Previous step</button>
                <button id="form-example-next-step" class="btn btn-primary w-100">Next step</button>
              </div>
              <!-- Buttons -->
            </div>
            <!-- Form wizrd -->
          
        
    
        
            
            const stepper = new mdb.Stepper(document.getElementById('stepper-form-example'));

            document.getElementById('form-example-next-step').addEventListener('click', () => {
              stepper.nextStep();
            });

            document.getElementById('form-example-prev-step').addEventListener('click', () => {
              stepper.previousStep();
            });
          
        
    

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
    invalid
  • step2
    invalid
  • step3
    invalid
        
            
            <ul
              class="stepper"
              data-mdb-stepper="stepper"
              data-mdb-stepper-vertical-breakpoint="768"
              data-mdb-stepper-mobile-breakpoint="400"
            >
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <i class="fas fa-user"></i>
                  </span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="toggle-to-vertical-input-1" class="form-control" required />
                      <label class="form-label" for="toggle-to-vertical-input-1">step 1</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <i class="fas fa-envelope"></i>
                  </span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="toggle-to-vertical-input-2" class="form-control" required />
                      <label class="form-label" for="toggle-to-vertical-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step" data-mdb-stepper-optional="true">
                <div class="stepper-head">
                  <span class="stepper-head-icon">
                    <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  </span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="toggle-to-vertical-input-3" class="form-control" required />
                      <label class="form-label" for="toggle-to-vertical-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
            </ul>
          
        
    

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.

  • 1 step1
    invalid
  • 2 step2
    invalid
  • 3 step3
    invalid
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-linear="true">
              <li class="stepper-step stepper-active">
                <div class="stepper-head">
                  <span class="stepper-head-icon">1</span>
                  <span class="stepper-head-text">step1</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="events-input-1" class="form-control" required />
                      <label class="form-label" for="events-input-1">step 1</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">2</span>
                  <span class="stepper-head-text">step2</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="events-input-2" class="form-control" required />
                      <label class="form-label" for="events-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
              <li class="stepper-step">
                <div class="stepper-head">
                  <span class="stepper-head-icon">3</span>
                  <span class="stepper-head-text">step3</span>
                </div>
                <div class="stepper-content py-3">
                  <form class="needs-validation" novalidate>
                    <div class="form-outline">
                      <input type="text" id="events-input-3" class="form-control" required />
                      <label class="form-label" for="events-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </form>
                </div>
              </li>
            </ul>
          
        
    
        
            
            document.querySelector('#linear-stepper .stepper').addEventListener('onValid.mdb.stepper', (e) => {
              console.log('onValid', e);
            });

            document.querySelector('#linear-stepper .stepper').addEventListener('onInvalid.mdb.stepper', (e) => {
              console.log('onInvalid', e);
            });

            document.querySelector('#linear-stepper .stepper').addEventListener('onChangeStep.mdb.stepper', (e) => {
              console.log('onChangeStep', e);
            });
          
        
    

Add custom validation

You can use the onChangeStep.mdb.stepper event to use your own validation.

  • 1 step1
    Password should have 5 or more characters
  • 2 step2
    invalid
  • 3 step3
    invalid
        
            
            <ul class="stepper" data-mdb-stepper="stepper" data-mdb-stepper-linear="true">
              <form class="needs-validation stepper-form" novalidate>
                <li class="stepper-step stepper-active">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">1</span>
                    <span class="stepper-head-text">step1</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="password" id="custom-validation-input-1" class="form-control" required />
                      <label class="form-label" for="custom-validation-input-1">password</label>
                      <div class="invalid-feedback">Password should have 5 or more characters</div>
                    </div>
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">2</span>
                    <span class="stepper-head-text">step2</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="text" id="custom-validation-input-2" class="form-control" required />
                      <label class="form-label" for="custom-validation-input-2">step 2</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </div>
                </li>
                <li class="stepper-step">
                  <div class="stepper-head">
                    <span class="stepper-head-icon">3</span>
                    <span class="stepper-head-text">step3</span>
                  </div>
                  <div class="stepper-content py-3">
                    <div class="form-outline">
                      <input type="text" id="custom-validation-input-3" class="form-control" required />
                      <label class="form-label" for="custom-validation-input-3">step 3</label>
                      <div class="invalid-feedback">invalid</div>
                    </div>
                  </div>
                </li>
              </form>
            </ul>
          
        
    
        
            
            document.querySelector('.stepper .stepper-step').addEventListener('onChangeStep.mdb.stepper', (e) => {
              const input = e.target.querySelector('.stepper-content input[type="password"]');
              const inputLenght = input.value.length;
              if (inputLenght < 5) {
                e.target.querySelector('input').setCustomValidity('Invalid');
                e.preventDefault();
              } else {
                e.target.querySelector('input').setCustomValidity('');
              }
            });
          
        
    

Stepper - API


Usage

Via data attributes

        
            
          <ul class="stepper" data-mdb-stepper="stepper">
            ...
          </ul>
        
        
    

Via JavaScript

        
            
          const stepper = new mdb.Stepper(document.getElementById('stepper'));
        
        
    

Via jQuery

Note: By default, MDB does not include jQuery and you have to add it to the project on your own.

        
            
          $(document).ready(() => {
            $('#stepper').stepper();
          });
        
        
    

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-mdb-, as in data-mdb-animations="".

Name Data attribute Type Default Description
animations data-mdb-animations String 'true' Set to false to turn off the animations displayed when step changes
stepperType data-mdb-stepper-type String 'horizontal' Set stepper view
stepperLinear data-mdb-stepper-linear Boolean false Set to true to use the linear stepper
stepperNoEditable data-mdb-stepper-no-editable Boolean false Set to true to block editing of the completed step
stepperHeadClick data-mdb-stepper-head-click Boolean true Set to false to block the possibility of changing a step by clicking on another step
stepperActive data-mdb-stepper-active String '' Set a custom active class
stepperCompleted data-mdb-stepper-completed String '' Set a custom completed class
stepperInvalid data-mdb-stepper-invalid String '' Set a custom invalid class
stepperDisabled data-mdb-stepper-disabled String '' Set a custom disabled class
stepperVerticalBreakpoint data-mdb-stepper-vertical-breakpoint Number 0 Set the resolution below which the stepper will switch to vertical
stepperMobileBreakpoint data-mdb-stepper-mobile-breakpoint Number 0 Set the resolution below which the stepper will switch to mobile
stepperMobileBarBreakpoint data-mdb-stepper-mobile-bar-breakpoint Number 4 Set the step limit after which the progress bar will appear in the mobile view instead of the dots
stepperMobileNextBtn data-mdb-stepper-mobile-next-btn String 'NEXT' Set custom text for NEXT button
stepperMobileBackBtn data-mdb-stepper-mobile-back-btn String 'BACK' Set custom text for BACK button
stepperMobileStepTxt data-mdb-stepper-mobile-step-txt String 'step' Set custom step value in the mobile stepper head
stepperMobileOfTxt data-mdb-stepper-mobile-of-txt String 'of' Set custom of value in the mobile stepper head

Methods

Name Description Example
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()
previousStep Switch to the previous step stepper.previousStep()
        
            
          const myStepperEl = document.getElementById('stepper');
          const stepper = new mdb.Stepper(myStepperEl);
          stepper.nextStep();
        
        
    

Events

Name Description
onChangeStep.mdb.stepper Event emitted before the step change
onValid.mdb.stepper Event emitted after successful step validation
onInvalid.mdb.stepper Event emitted after unsuccessful step validation
        
            
          const stepOne = document.querySelectorAll('.stepper .stepper-step')[0];
          stepOne.addEventListener('onChangeStep.mdb.stepper', () => {
            // do something...
          });
        
        
    

Import

MDB UI KIT also works with module bundlers. Use the following code to import this component:

        
            
          import { Stepper } from 'mdb-ui-kit';
        
        
    

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.

        
            
          // .steps
          --#{$prefix}steps-transition: #{$steps-transition};

          // .steps-step
          --#{$prefix}steps-step-after-left: #{$steps-step-after-left};
          --#{$prefix}steps-step-after-width: #{$steps-step-after-width};
          --#{$prefix}steps-step-after-margin-top: #{$steps-step-after-margin-top};
          --#{$prefix}steps-step-after-bg: #{$steps-step-after-bg};

          // .steps-content
          --#{$prefix}steps-content-padding-y: #{$steps-content-padding-y};

          // .steps-head-vertical
          --#{$prefix}steps-head-vertical-padding-top: #{$steps-head-vertical-padding-top};
          --#{$prefix}steps-head-vertical-padding-x: #{$steps-head-vertical-padding-x};

          // .steps-head-icon-vertical
          --#{$prefix}steps-head-icon-vertical-margin-right: #{$steps-head-icon-vertical-margin-right};

          // .steps-head
          --#{$prefix}steps-head-line-height: #{$steps-head-line-height};
          --#{$prefix}steps-head-hover-bgc: #{$steps-head-hover-bgc};

          // .steps-head-text
          --#{$prefix}steps-head-text-color: #{$steps-head-text-color};
          --#{$prefix}steps-head-text-after-font-size: #{$steps-head-text-after-font-size};

          // .steps-head-icon
          --#{$prefix}steps-head-icon-font-size: #{$steps-head-icon-font-size};
          --#{$prefix}steps-head-icon-width: #{$steps-head-icon-width};
          --#{$prefix}steps-head-icon-height: #{$steps-head-icon-height};
          --#{$prefix}steps-head-icon-font-weight: #{$steps-head-icon-font-weight};

          // .steps-active-head-text
          --#{$prefix}steps-active-head-text-font-weight: #{$steps-active-head-text-font-weight};
          
          // .stepper
          --#{$prefix}stepper-padding-x: #{$stepper-padding-x};
          --#{$prefix}stepper-step-height: #{$stepper-step-height};
          --#{$prefix}stepper-step-head-padding-left: #{$stepper-step-head-padding-left};
          --#{$prefix}stepper-step-head-padding-right: #{$stepper-step-head-padding-right};
          --#{$prefix}stepper-step-head-height: #{$stepper-step-head-height};
          --#{$prefix}stepper-step-head-bg: #{$stepper-step-head-bg};
          --#{$prefix}stepper-step-head-margin-right: #{$stepper-step-head-margin-right};
          --#{$prefix}stepper-step-head-margin-left: #{$stepper-step-head-margin-left};
          --#{$prefix}stepper-head-icon-margin-y: #{$stepper-head-icon-margin-y};
          --#{$prefix}stepper-head-icon-margin-right: #{$stepper-head-icon-margin-right};
          --#{$prefix}stepper-vertical-step-top: #{$stepper-vertical-step-top};
          --#{$prefix}stepper-vertical-step-height: #{$stepper-vertical-step-height};
          --#{$prefix}stepper-vertical-content-padding-left: #{$stepper-vertical-content-padding-left};
          --#{$prefix}stepper-vertical-content-transition: #{$stepper-vertical-content-transition};
          --#{$prefix}stepper-vertical-head-padding-bottom: #{$stepper-vertical-head-padding-bottom};
          --#{$prefix}stepper-mobile-step-margin-y: #{$stepper-mobile-step-margin-y};
          --#{$prefix}stepper-mobile-step-head-padding-x: #{$stepper-mobile-step-head-padding-x};
          --#{$prefix}stepper-mobile-head-icon-height: #{$stepper-mobile-head-icon-height};
          --#{$prefix}stepper-mobile-head-icon-width: #{$stepper-mobile-head-icon-width};
          --#{$prefix}stepper-mobile-content-top: #{$stepper-mobile-content-top};
          --#{$prefix}stepper-mobile-active-head-icon-bg: #{$stepper-mobile-active-head-icon-bg};
          --#{$prefix}stepper-mobile-completed-head-icon-bg: #{$stepper-mobile-completed-head-icon-bg};
          --#{$prefix}stepper-head-icon-bg: #{$stepper-head-icon-bg};
          --#{$prefix}stepper-head-icon-color: #{$stepper-head-icon-color};
          --#{$prefix}stepper-completed-head-icon-bg: #{$stepper-completed-head-icon-bg};
          --#{$prefix}stepper-completed-head-icon-color: #{$stepper-completed-head-icon-color};
          --#{$prefix}stepper-active-head-icon-bg: #{$stepper-active-head-icon-bg};
          --#{$prefix}stepper-active-head-icon-color: #{$stepper-active-head-icon-color};
          --#{$prefix}stepper-invalid-head-icon-bg: #{$stepper-invalid-head-icon-bg};
          --#{$prefix}stepper-invalid-head-icon-color: #{$stepper-invalid-head-icon-color};
          --#{$prefix}stepper-disabled-head-color: #{$stepper-disabled-head-color};
          --#{$prefix}stepper-disabled-head-icon-bg: #{$stepper-disabled-head-icon-bg};
          --#{$prefix}stepper-disabled-head-icon-color: #{$stepper-disabled-head-icon-color};
          --#{$prefix}stepper-mobile-head-padding-y: #{$stepper-mobile-head-padding-y};
          --#{$prefix}stepper-mobile-head-padding-x: #{$stepper-mobile-head-padding-x};
          --#{$prefix}stepper-mobile-footer-height: #{$stepper-mobile-footer-height};
          --#{$prefix}stepper-back-btn-i-margin-right: #{$stepper-back-btn-i-margin-right};
          --#{$prefix}stepper-next-btn-i-margin-left: #{$stepper-next-btn-i-margin-left};
          --#{$prefix}stepper-mobile-progress-bar-height: #{$stepper-mobile-progress-bar-height};
          --#{$prefix}stepper-mobile-progress-height: #{$stepper-mobile-progress-height};
          --#{$prefix}stepper-mobile-progress-background-color: #{$stepper-mobile-progress-background-color};
          
        
    

SCSS variables

        
            
        // Steps
        $steps-transition: height 0.2s ease-in-out;
        
        $steps-step-after-left: 2.45rem;
        $steps-step-after-width: 1px;
        $steps-step-after-margin-top: 0.5rem;
        $steps-step-after-bg: #dfdfdf;
        
        $steps-content-padding-y: 1.5rem;
        
        $steps-head-vertical-padding-top: 1.5rem;
        $steps-head-vertical-padding-x: 1.5rem;
        
        $steps-head-icon-vertical-margin-right: 0.75rem;
        
        $steps-head-line-height: 1.3;
        $steps-head-hover-bgc: rgba(0, 0, 0, 0.025);
        
        $steps-head-text-color: $text-muted;
        $steps-head-text-after-font-size: 0.8rem;
        
        $steps-head-icon-font-size: 0.875rem;
        $steps-head-icon-width: 1.938rem;
        $steps-head-icon-height: 1.938rem;
        $steps-head-icon-font-weight: 500;
        
        $steps-active-head-text-font-weight: 500;
        
        // Stepper
        $stepper-padding-x: 1rem;
        
        $stepper-step-height: 4.5rem;
        
        $stepper-step-head-padding-left: 1.5rem;
        $stepper-step-head-padding-right: 1.5rem;
        $stepper-step-head-height: 1px;
        $stepper-step-head-bg: rgba(0, 0, 0, 0.1);
        $stepper-step-head-margin-right: 0.5rem;
        $stepper-step-head-margin-left: 0.5rem;
        
        $stepper-head-icon-margin-y: 1.5rem;
        $stepper-head-icon-margin-right: 0.5rem;
        
        $stepper-vertical-step-top: 3.25rem;
        $stepper-vertical-step-height: calc(100% - 2.45rem);
        $stepper-vertical-content-padding-left: 3.75rem;
        $stepper-vertical-content-transition: height 0.3s ease-in-out, margin-top 0.3s ease-in-out,
          margin-bottom 0.3s ease-in-out, padding-top 0.3s ease-in-out, padding-bottom 0.3s ease-in-out;
        $stepper-vertical-head-padding-bottom: 1.5rem;
        
        $stepper-mobile-step-margin-y: 1rem;
        $stepper-mobile-step-head-padding-x: 0.25rem;
        $stepper-mobile-head-icon-height: 0.5rem;
        $stepper-mobile-head-icon-width: 0.5rem;
        $stepper-mobile-content-top: 2.56rem;
        $stepper-mobile-active-head-icon-bg: rgb(55, 111, 200);
        $stepper-mobile-completed-head-icon-bg: rgb(19, 150, 71);
        
        $stepper-head-icon-bg: rgb(235, 237, 239);
        $stepper-head-icon-color: rgb(64, 70, 79);
        
        $stepper-completed-head-icon-bg: rgb(214, 240, 224);
        $stepper-completed-head-icon-color: rgb(13, 104, 50);
        
        $stepper-active-head-icon-bg: rgb(223, 231, 246);
        $stepper-active-head-icon-color: rgb(44, 88, 160);
        
        $stepper-invalid-head-icon-bg: rgb(249, 225, 229);
        $stepper-invalid-head-icon-color: rgb(175, 35, 58);
        
        $stepper-disabled-head-color: #808080;
        $stepper-disabled-head-icon-bg: #e6e6e6;
        $stepper-disabled-head-icon-color: #808080;
        
        $stepper-mobile-head-padding-y: 0.5rem;
        $stepper-mobile-head-padding-x: 1rem;
        $stepper-mobile-footer-height: 2.5rem;
        
        $stepper-back-btn-i-margin-right: 0.5rem;
        $stepper-next-btn-i-margin-left: 0.5rem;
        
        $stepper-mobile-progress-bar-height: 0.3rem;
        $stepper-mobile-progress-height: 0.3rem;
        $stepper-mobile-progress-background-color: $gray-300;