![]() |
VOOZH | about |
A website can have dialogues added for lightboxes, user notifications, or entirely unique content by using Bootstrap modals. A modal is made up of components like the dialog, content, header, title, body, and footer. A modal can be used to implement a lot of utilities like showing a message or popping open the logging-in portal.
Bootstrap 5 Modal Components: To create a modal you will need multiple components, like a header, body, footer, etc. Each component has it's own class and all the components that can be used to create a modal are described below with the class.
Syntax:
<div class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
<!-- Modal title goes Here --!>
</h5>
</div>
<div class="modal-body">
<!-- Modal body text goes here --!>
</div>
<div class="modal-footer">
<!-- Modal Footer text goes here --!>
</div>
</div>
</div>
</div>
Example 1: The code below demonstrates how we can use the different components of a modal.
Output:
Example 2: The code below demonstrates how we can use the different components of a modal and also add dynamic heights to a modal using jQuery.
Note: Here in this example, we used display: none; property, .d-none class will not work in this case
Output:
Reference: https://getbootstrap.com/docs/5.0/components/modal/#modal-components