content logo

Bootstrap Popups:

Bootstrap Step Wizard Modal

In this post, we have prepared one of the best bootstraps. This is the Bootstrap Step Wizard Modal with a different theme and you can use it to make your website beautiful. By using this Bootstrap Modal Code, you can explain the processes and steps of doing a job easily. If you have a website and need to introduce the process of filling out a form or other jobs, this HTML Modal Wizard Code can be helpful.

This beautiful code has a dark blue background with some oblique white lines. There is a black square in the center of the page and you can see another gray square in the middle of the black one. The text of this Popup Wizard Code is white. When you click on this button, you will face a white page with black text. You can see the steps of that job at the top of the page and there is a line under this part. There are two fields at the end of each step with a blue theme. As you click on the blue button, you move to the next step and the white button leads you to the previous page of the JavaScript Step Popup.

#

Bootstrap Modal Code

#

HTML Modal Wizard Code

#

Popup Wizard Code

#

Javascript Step Popup

<!-- This script got from frontendfreecode.com -->
<div class="container h-100">
    <div class="row justify-content-center align-items-center h-100">
        <div class="col-6">
            <div class="bg-dark p-5 text-center rounded shadow-lg">
                <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#modal-test">
                    Launch demo modal
                </button>
            </div>
        </div>
    </div>
</div>
<div id="modal-test" class="modal modal-steps fade" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-steps-list">
                    <div id="step-1" class="modal-step step-active">
                        <h2>Step 1</h2>
                        <p>Modal</p>
                    </div>
                    <div id="step-3" class="modal-step">
                        <h2>Step 2</h2>
                        <p>How to use</p>
                    </div>
                    <div id="step-2" class="modal-step">
                        <h2>Step 3</h2>
                        <p>Enjoy</p>
                    </div>
                </div>
            </div>
            <div class="modal-body">
                <div class="modal-step-body step-active" data-mstep='#step-1'>
                    <p>A really simple jQuery plugin to make a bootstrap modal with steps.</p>
                    <b>jQuery code</b>
                    <div class="bg-light p-3 mb-3">
                        <code class="d-block text-muted">// Use the bootstrap modal as element</code>
                        <code class="d-block">
                            $(element).stepModal();
                        </code>
                    </div>
                    <b>Options & events</b>
                    <div class="bg-light p-3 mb-3">
                        <code class="d-block">
                            $(element).stepModal({
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;stepListClickable: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;prevBtnCancelTextActive: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;prevBtnCancelText: 'Cancel',
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;nextBtnFinishTextActive: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;nextBtnFinishText: 'Finish',
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;onFinish: function(){},
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;onCancel: function(){},
                        </code>
                        <code class="d-block">
                            });
                        </code>
                    </div>
                </div>
                <div class="modal-step-body" data-mstep='#step-2'>
                    <p>This plugin doesn't generate HTML. You have to make the HTML yourself. Check the codepen source to view the HTML code. Don't forget to include the step buttons!</p>
                </div>
                <div class="modal-step-body" data-mstep='#step-3'>
                    <p>And here you are, a working step modal plugin. Free to use.</p>
                </div>
            </div>
            <div class="modal-footer">
                <div class="m-auto">
                    <button type="button" class="btn btn-outline-primary" data-mstep-btn="previous">Previous step</button>
                    <button type="button" class="btn btn-primary" data-mstep-btn="next">Next step</button>
                </div>
            </div>
        </div>
    </div>
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
html {
  height: 100%;
}
body {
  height: 100%;
  background: #2A2E45;
}
body:before {
  z-index: -1;
  content: "";
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(120deg, #343956, #343956 2px, transparent 2px, transparent 17.5vw);
  position: absolute;
}
.modal.modal-steps .modal-header {
  padding: 0;
  border-bottom: 0;
}
.modal.modal-steps .modal-steps-list {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.modal.modal-steps .modal-steps-list .modal-step {
  text-align: center;
  flex: 1 0 0px;
  border-bottom: 2px solid #dee2e6;
  padding: 1rem 0;
}
.modal.modal-steps .modal-steps-list .modal-step h1, .modal.modal-steps .modal-steps-list .modal-step h2, .modal.modal-steps .modal-steps-list .modal-step h3, .modal.modal-steps .modal-steps-list .modal-step h4, .modal.modal-steps .modal-steps-list .modal-step h5, .modal.modal-steps .modal-steps-list .modal-step h6 {
  padding: 0;
  margin: 0;
  font-size: 0.75em;
  font-weight: bold;
}
.modal.modal-steps .modal-steps-list .modal-step p {
  padding: 0;
  margin: 0;
  font-size: 1.25em;
}
.modal.modal-steps .modal-steps-list .modal-step.step-active {
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}
.modal.modal-steps .modal-step-body {
  display: none;
}
.modal.modal-steps .modal-step-body.step-active {
  display: block;
}
window.onload = function () {
    if (!window.jQuery)
        console.error("Step modal plugin needs jQuery in order to work...");
}
var stepModalObjectHolder = function (element, options) {
    // search for modals
    if ($(element).length < 1 || !$(element).hasClass("modal-steps"))
        return console.error("No modal found");
    var bootstrapModal = new bootstrap.Modal(element);
    var options = (typeof options !== 'undefined' ? options : {})
    this.options = {
        stepListClickable: (typeof options.stepListClickable !== 'undefined' ? options.stepListClickable : true),
        prevBtnCancelTextActive: (typeof options.prevBtnCancelTextActive !== 'undefined' ? options.prevBtnCancelTextActive : true),
        prevBtnCancelText: (typeof options.prevBtnCancelText !== 'undefined' ? options.prevBtnCancelText : 'Cancel'),
        nextBtnFinishTextActive: (typeof options.nextBtnFinishTextActive !== 'undefined' ? options.nextBtnFinishTextActive : true),
        nextBtnFinishText: (typeof options.nextBtnFinishText !== 'undefined' ? options.nextBtnFinishText : 'Finish'),
        onFinish: function(){
			  (typeof options.onFinish !== 'undefined' ? options.onFinish : function () {});
			  bootstrapModal.hide()
		  },
        onCancel: function(){
			 (typeof options.onFinish !== 'undefined' ? options.onCancel : function () {});
			  bootstrapModal.hide()
		  },
    };
    this.element = $(element);
    this.uid = (Math.random() + 1).toString(36).substring(10);
    this.currentstep = 0;
    var steps = new Array;
    element.find('.modal-steps-list .modal-step').each(function () {
        var elementid = $(this).attr('id');
        // check if step has id otherwise create 
        if (typeof elementid == "undefined") {
            elementid = 'modalstep-' + (Math.random() + 1).toString(36).substring(4);
            $(this).attr('id', elementid)
        }
        steps.push(elementid);
    });
    // Link the modal body
    element.find('.modal-step-body').each(function (i) {
        var linkedto = $(this).attr('data-mstep');
        // check if body has id otherwise create 
        if (typeof elementid == "undefined") {
            linkedto = '#' + steps[i];
            $(this).attr('data-mstep', linkedto)
        }
    });
    this.steps = steps;
    this.btn = {
        next: element.find("[data-mstep-btn='next']"),
        prev: element.find("[data-mstep-btn='previous']"),
        texts: {
            next: element.find("[data-mstep-btn='next']").html(),
            prev: element.find("[data-mstep-btn='previous']").html()
        }
    }
    // control the modal
    this.control = function () {
        var object = this;
        var modalBodies = element.find('.modal-step-body');
        var max = (object.steps.length - 1);
        return {
            nextStep: function () {
                object.currentstep = object.currentstep + 1;
                if (object.currentstep > max)
                    return this.finish();
                this.refresh();
            },
            prevStep: function () {
                object.currentstep = object.currentstep - 1;
                if (object.currentstep < 0)
                    return this.cancel();
                this.refresh();
            },
            setStep: function (step) {
                if (step > max)
                    return console.error("max steps");
                object.currentstep = step;
                this.refresh();
            },
            refresh: function () {
                if (object.currentstep == 0 && object.options.prevBtnCancelTextActive === true) {
                    object.btn.prev.html(object.options.prevBtnCancelText);
                } else {
                    object.btn.prev.html(object.btn.texts.prev);
                }
                if (object.currentstep == max && object.options.nextBtnFinishTextActive === true) {
                    object.btn.next.html(object.options.nextBtnFinishText);
                } else {
                    object.btn.next.html(object.btn.texts.next);
                }
                object.steps.forEach((id, index) => {
                    modalBodies.removeClass('step-active');
                    $("#" + id).removeClass('step-active');
                    if (index == object.currentstep) {
                        setTimeout(function () {
                            $("#" + id).addClass('step-active');
                            $(".modal-step-body[data-mstep='#" + id + "']").addClass('step-active');
                        }, 10);
                    }
                });
            },
            finish: function () {
                object.currentstep = 0;
                $(element).trigger('finish');
				
            },
            cancel: function () {
                object.currentstep = 0;
                $(element).trigger('cancel');
            }
        }
    }
    this.control().refresh();
    var modalobject = this;
    if (typeof this.btn.next !== 'undefined') {
        this.btn.next.off();
        this.btn.next.on('click', function () {
            modalobject.control().nextStep();
        });
    }
    if (typeof this.btn.prev !== 'undefined') {
        this.btn.prev.off();
        this.btn.prev.on('click', function () {
            modalobject.control().prevStep();
        });
    }
    if (this.options.stepListClickable) {
        element.find('.modal-steps-list .modal-step').css('cursor', 'pointer');
        element.find('.modal-steps-list .modal-step').on('click', function () {
            modalobject.control().setStep($(this).index());
        });
    }
};
(function ($) {
    $.fn.stepModal = function (options) {
        var modalObject = new stepModalObjectHolder($(this), options);
        $(modalObject.element).bind("finish", function () {
            modalObject.options.onFinish();
        });
        $(modalObject.element).bind("cancel", function () {
            modalObject.options.onCancel();
        });
        return modalObject;
    };
})(jQuery);
$(document).ready(function () {
    var theModal = $(".modal-steps").stepModal();
})
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js'></script>
<style>
html {
  height: 100%;
}
body {
  height: 100%;
  background: #2A2E45;
}
body:before {
  z-index: -1;
  content: "";
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(120deg, #343956, #343956 2px, transparent 2px, transparent 17.5vw);
  position: absolute;
}
.modal.modal-steps .modal-header {
  padding: 0;
  border-bottom: 0;
}
.modal.modal-steps .modal-steps-list {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.modal.modal-steps .modal-steps-list .modal-step {
  text-align: center;
  flex: 1 0 0px;
  border-bottom: 2px solid #dee2e6;
  padding: 1rem 0;
}
.modal.modal-steps .modal-steps-list .modal-step h1, .modal.modal-steps .modal-steps-list .modal-step h2, .modal.modal-steps .modal-steps-list .modal-step h3, .modal.modal-steps .modal-steps-list .modal-step h4, .modal.modal-steps .modal-steps-list .modal-step h5, .modal.modal-steps .modal-steps-list .modal-step h6 {
  padding: 0;
  margin: 0;
  font-size: 0.75em;
  font-weight: bold;
}
.modal.modal-steps .modal-steps-list .modal-step p {
  padding: 0;
  margin: 0;
  font-size: 1.25em;
}
.modal.modal-steps .modal-steps-list .modal-step.step-active {
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}
.modal.modal-steps .modal-step-body {
  display: none;
}
.modal.modal-steps .modal-step-body.step-active {
  display: block;
}
</style>

</head>
<body>
<div class="container h-100">
    <div class="row justify-content-center align-items-center h-100">
        <div class="col-6">
            <div class="bg-dark p-5 text-center rounded shadow-lg">
                <button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#modal-test">
                    Launch demo modal
                </button>
            </div>
        </div>
    </div>
</div>
<div id="modal-test" class="modal modal-steps fade" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-steps-list">
                    <div id="step-1" class="modal-step step-active">
                        <h2>Step 1</h2>
                        <p>Modal</p>
                    </div>
                    <div id="step-3" class="modal-step">
                        <h2>Step 2</h2>
                        <p>How to use</p>
                    </div>
                    <div id="step-2" class="modal-step">
                        <h2>Step 3</h2>
                        <p>Enjoy</p>
                    </div>
                </div>
            </div>
            <div class="modal-body">
                <div class="modal-step-body step-active" data-mstep='#step-1'>
                    <p>A really simple jQuery plugin to make a bootstrap modal with steps.</p>
                    <b>jQuery code</b>
                    <div class="bg-light p-3 mb-3">
                        <code class="d-block text-muted">// Use the bootstrap modal as element</code>
                        <code class="d-block">
                            $(element).stepModal();
                        </code>
                    </div>
                    <b>Options & events</b>
                    <div class="bg-light p-3 mb-3">
                        <code class="d-block">
                            $(element).stepModal({
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;stepListClickable: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;prevBtnCancelTextActive: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;prevBtnCancelText: 'Cancel',
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;nextBtnFinishTextActive: true,
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;nextBtnFinishText: 'Finish',
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;onFinish: function(){},
                        </code>
                        <code class="me-3 d-block">
                            &nbsp;&nbsp;&nbsp;onCancel: function(){},
                        </code>
                        <code class="d-block">
                            });
                        </code>
                    </div>
                </div>
                <div class="modal-step-body" data-mstep='#step-2'>
                    <p>This plugin doesn't generate HTML. You have to make the HTML yourself. Check the codepen source to view the HTML code. Don't forget to include the step buttons!</p>
                </div>
                <div class="modal-step-body" data-mstep='#step-3'>
                    <p>And here you are, a working step modal plugin. Free to use.</p>
                </div>
            </div>
            <div class="modal-footer">
                <div class="m-auto">
                    <button type="button" class="btn btn-outline-primary" data-mstep-btn="previous">Previous step</button>
                    <button type="button" class="btn btn-primary" data-mstep-btn="next">Next step</button>
                </div>
            </div>
        </div>
    </div>
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
window.onload = function () {
    if (!window.jQuery)
        console.error("Step modal plugin needs jQuery in order to work...");
}
var stepModalObjectHolder = function (element, options) {
    // search for modals
    if ($(element).length < 1 || !$(element).hasClass("modal-steps"))
        return console.error("No modal found");
    var bootstrapModal = new bootstrap.Modal(element);
    var options = (typeof options !== 'undefined' ? options : {})
    this.options = {
        stepListClickable: (typeof options.stepListClickable !== 'undefined' ? options.stepListClickable : true),
        prevBtnCancelTextActive: (typeof options.prevBtnCancelTextActive !== 'undefined' ? options.prevBtnCancelTextActive : true),
        prevBtnCancelText: (typeof options.prevBtnCancelText !== 'undefined' ? options.prevBtnCancelText : 'Cancel'),
        nextBtnFinishTextActive: (typeof options.nextBtnFinishTextActive !== 'undefined' ? options.nextBtnFinishTextActive : true),
        nextBtnFinishText: (typeof options.nextBtnFinishText !== 'undefined' ? options.nextBtnFinishText : 'Finish'),
        onFinish: function(){
			  (typeof options.onFinish !== 'undefined' ? options.onFinish : function () {});
			  bootstrapModal.hide()
		  },
        onCancel: function(){
			 (typeof options.onFinish !== 'undefined' ? options.onCancel : function () {});
			  bootstrapModal.hide()
		  },
    };
    this.element = $(element);
    this.uid = (Math.random() + 1).toString(36).substring(10);
    this.currentstep = 0;
    var steps = new Array;
    element.find('.modal-steps-list .modal-step').each(function () {
        var elementid = $(this).attr('id');
        // check if step has id otherwise create 
        if (typeof elementid == "undefined") {
            elementid = 'modalstep-' + (Math.random() + 1).toString(36).substring(4);
            $(this).attr('id', elementid)
        }
        steps.push(elementid);
    });
    // Link the modal body
    element.find('.modal-step-body').each(function (i) {
        var linkedto = $(this).attr('data-mstep');
        // check if body has id otherwise create 
        if (typeof elementid == "undefined") {
            linkedto = '#' + steps[i];
            $(this).attr('data-mstep', linkedto)
        }
    });
    this.steps = steps;
    this.btn = {
        next: element.find("[data-mstep-btn='next']"),
        prev: element.find("[data-mstep-btn='previous']"),
        texts: {
            next: element.find("[data-mstep-btn='next']").html(),
            prev: element.find("[data-mstep-btn='previous']").html()
        }
    }
    // control the modal
    this.control = function () {
        var object = this;
        var modalBodies = element.find('.modal-step-body');
        var max = (object.steps.length - 1);
        return {
            nextStep: function () {
                object.currentstep = object.currentstep + 1;
                if (object.currentstep > max)
                    return this.finish();
                this.refresh();
            },
            prevStep: function () {
                object.currentstep = object.currentstep - 1;
                if (object.currentstep < 0)
                    return this.cancel();
                this.refresh();
            },
            setStep: function (step) {
                if (step > max)
                    return console.error("max steps");
                object.currentstep = step;
                this.refresh();
            },
            refresh: function () {
                if (object.currentstep == 0 && object.options.prevBtnCancelTextActive === true) {
                    object.btn.prev.html(object.options.prevBtnCancelText);
                } else {
                    object.btn.prev.html(object.btn.texts.prev);
                }
                if (object.currentstep == max && object.options.nextBtnFinishTextActive === true) {
                    object.btn.next.html(object.options.nextBtnFinishText);
                } else {
                    object.btn.next.html(object.btn.texts.next);
                }
                object.steps.forEach((id, index) => {
                    modalBodies.removeClass('step-active');
                    $("#" + id).removeClass('step-active');
                    if (index == object.currentstep) {
                        setTimeout(function () {
                            $("#" + id).addClass('step-active');
                            $(".modal-step-body[data-mstep='#" + id + "']").addClass('step-active');
                        }, 10);
                    }
                });
            },
            finish: function () {
                object.currentstep = 0;
                $(element).trigger('finish');
				
            },
            cancel: function () {
                object.currentstep = 0;
                $(element).trigger('cancel');
            }
        }
    }
    this.control().refresh();
    var modalobject = this;
    if (typeof this.btn.next !== 'undefined') {
        this.btn.next.off();
        this.btn.next.on('click', function () {
            modalobject.control().nextStep();
        });
    }
    if (typeof this.btn.prev !== 'undefined') {
        this.btn.prev.off();
        this.btn.prev.on('click', function () {
            modalobject.control().prevStep();
        });
    }
    if (this.options.stepListClickable) {
        element.find('.modal-steps-list .modal-step').css('cursor', 'pointer');
        element.find('.modal-steps-list .modal-step').on('click', function () {
            modalobject.control().setStep($(this).index());
        });
    }
};
(function ($) {
    $.fn.stepModal = function (options) {
        var modalObject = new stepModalObjectHolder($(this), options);
        $(modalObject.element).bind("finish", function () {
            modalObject.options.onFinish();
        });
        $(modalObject.element).bind("cancel", function () {
            modalObject.options.onCancel();
        });
        return modalObject;
    };
})(jQuery);
$(document).ready(function () {
    var theModal = $(".modal-steps").stepModal();
})
</script>

</body>
</html>
Preview