Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I customize the default Bootstrap modal animation? Pending Review
Asked on Apr 13, 2026
Answer
To customize the default Bootstrap modal animation, you can override the default CSS transitions. Bootstrap uses CSS transitions for modal animations, and you can modify these by adding your own CSS rules.
<!-- BEGIN COPY / PASTE -->
<style>
.modal.fade .modal-dialog {
transition: transform 0.3s ease-out, opacity 0.3s ease-out;
transform: translateY(-50px);
opacity: 0;
}
.modal.show .modal-dialog {
transform: translateY(0);
opacity: 1;
}
</style>
<div class="modal fade" id="customModal" tabindex="-1" aria-labelledby="customModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customModalLabel">Custom Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
This is a custom animated modal.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- The CSS rules above modify the default animation by changing the `transform` and `opacity` properties.
- The `.modal.fade .modal-dialog` class sets the initial state of the modal with a slight upward translation and zero opacity.
- The `.modal.show .modal-dialog` class defines the final state with no translation and full opacity.
- You can adjust the `transform` values and `transition` duration to achieve different animation effects.
- Ensure your custom styles are loaded after the Bootstrap CSS to override the defaults.
Recommended Links:
