![]() |
VOOZH | about |
Bootstrap 5Modal option can be used in two ways using data attributes and using JavaScript. Options are added to append different utilities and properties to the modal like having a backdrop on the background while the modal is open, etc.
The following are the option that is replaceable with * of data-bs-*:
<div class="modal" data-bs-*=value>
<!-- Modal Content --!>
</div>
Note: The * in the data-bs-* is replaced by the name of one of the options given above.
Example 1: The code below demonstrates the disabling of the backdrop and adding keyboard modal options along with adding dynamic height to the modal.
Output:
Example 2: The code below demonstrates the usage of the backdrop and focus modal options along with adding a grid to the modal. The backdrop is static, so clicking on the backdrop will not close the modal.
Output:
Reference: https://getbootstrap.com/docs/5.0/components/modal/#options