To change the color via:

CSS

Put these styles in your stylesheet after the bootstrap styles:

.modal-backdrop {
   background-color: red;
}

Less

Changes the bootstrap-variables to:

@modal-backdrop-bg:           red;

Source

Sass

Changes the bootstrap-variables to:

$modal-backdrop-bg:           red;

Source

Bootstrap-Customizer

Change @modal-backdrop-bg to your desired color:

getbootstrap.com/customize/


You can also remove the backdrop via Javascript or by setting the color to transparent.

Answer from HaNdTriX on Stack Overflow
🌐
Codeply
codeply.com › go › oNKsVikW6n
Bootstrap 4 modal backdrop color on Codeply
HTML, CSS, JavaScript editor playground for designers & developers to compare, prototype and test frontend frameworks
🌐
SitePoint
sitepoint.com › html & css
Modal background - HTML & CSS - SitePoint Forums | Web Development & Design Community
April 29, 2018 - .modal-overlay { display: none; justify-content: center; align-items: center; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color: rgba(0, 0, 0, .5); opacity: 0; transiti…
Top answer
1 of 9
78

You can use the css below, put this in your custom css to override the bootstrap css.

.modal-header {
    padding:9px 15px;
    border-bottom:1px solid #eee;
    background-color: #0480be;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    -moz-border-radius-topleft: 5px;
    -moz-border-radius-topright: 5px;
     border-top-left-radius: 5px;
     border-top-right-radius: 5px;
 }
2 of 9
23

So, I tried these other ways, but there was a VERY slight irritant and that was if you keep the modal-content border radius, in FF and Chrome, there is a slight bit of white trim showing along the borders, even if you use 5px on the modal-header border radius. (standard modal-content border radius is 6px, so 5px on the modal-header border top radius covers some white).

My solution:

.modal-body
{
    background-color: #FFFFFF;
}

.modal-content
{
    border-radius: 6px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    background-color: transparent;
}

.modal-footer
{
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    -webkit-border-bottom-left-radius: 6px;
    -webkit-border-bottom-right-radius: 6px;
    -moz-border-radius-bottomleft: 6px;
    -moz-border-radius-bottomright: 6px;
}

.modal-header
{
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    -webkit-border-top-left-radius: 6px;
    -webkit-border-top-right-radius: 6px;
    -moz-border-radius-topleft: 6px;
    -moz-border-radius-topright: 6px;
}

!! CAVEAT !!

You must then set the background colors of the modal-header, modal-content, and modal-footer. This is not bad trade-off, because it allows you to do this:

<div class="modal-header bg-primary">

<div class="modal-body bgColorWhite">

<div class="modal-footer bg-info">

EDIT

Or even better:

<div class="modal-header alert-primary">
🌐
Bootstrap
getbootstrap.com › docs › 4.4 › components › modal
Modal · Bootstrap
Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
🌐
Wappler Community
community.wappler.io › wappler general › need help
Change Modal Header Color - Need Help - Wappler Community
February 23, 2023 - Try this… go to your custom css file or hard code it in the page and add the bootstrap background color there: class=“modal-header bg- your choice”
Find elsewhere
🌐
Bootsnipp
bootsnipp.com › snippets › dzvv
Bootstrap Snippet Colored Modal Headings using HTML CSS
.modal-header-success { color:#fff; padding:9px 15px; border-bottom:1px solid #eee; background-color: #5cb85c; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .modal-header-warning { color:#fff; padding:9px 15px; border-bottom:1px solid #eee; background-color: #f0ad4e; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; bord
🌐
Font Awesome
fontawesomeicons.com › fa › bootstrap-change-modal-background-color
Bootstrap Change modal background color | modal-backdrop
For instance, .modal-custom .modal-backdrop { background-color: #FF0000; }. This selector targets the modal with the custom class and the modal backdrop, allowing you to set the desired background color. ... Thanks for your feedback! Your contributions will help us to improve service.
🌐
GitHub
github.com › react-bootstrap › react-bootstrap › issues › 2262
How to set a color for the backdrop background of the modal? · Issue #2262 · react-bootstrap/react-bootstrap
May 11, 2016 - Hi guys, I have an issue with the modal component and I need your help. I want to change the background color of the modal backdrop. I want to have multiple modals in the page and each of them to have a specific color. The problem that I...
Author   nicotsou
🌐
MDBootstrap
mdbootstrap.com › standard › modal backdrop
Bootstrap Modal Backdrop - free examples & tutorial
<!-- Button trigger modal --> <button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-primary" data-mdb-modal-init data-mdb-target="#exampleModal"> Launch demo modal </button> <!-- Modal --> <div class="modal top fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" data-mdb-backdrop="true" data-mdb-keyboard="true"> <div class="modal-dialog "> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Modal title</h5> <button type="button" data-mdb-button-init data-mdb-ripple-init class="bt
🌐
W3Schools
w3schools.com › bootstrap › tryit.asp
Modal Options
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
GitHub
github.com › bootstrap-vue › bootstrap-vue › issues › 4493
modal-content background-color with variable · Issue #4493 · bootstrap-vue/bootstrap-vue
December 12, 2019 - .modal-content { background-color: var(--primary-background); } Adding normal color, like #ff0000 work perfectly normal. The same behavior should have an variable. Libraries: BootstrapVue: 2.1.0 · nuxt 2.5.1 · Environment: OS: Fedora 31 · Browser: Firefox ·
Author   jb-alvarado
🌐
Bootstrap Studio Forum
forum.bootstrapstudio.io › tips and tricks
Change color of modal close button from dark to light in Bootstrap 5 - Tips and Tricks - Bootstrap Studio Forum
July 30, 2022 - The Bootstrap 5 modal uses an SVG background image for the “X” close button (unlike Bootstrap 4, which used a font.) Changing the color of the close button in Bootstrap 4 was easily done by changing the color: rule on the .close class.
🌐
GitHub
github.com › twbs › bootstrap › issues › 10030
Modal background pitch black (no transparency) when customized · Issue #10030 · twbs/bootstrap
August 22, 2013 - Hi! I just generated a customized version and the modal background is totally black (I also generated a version without any change to be sure it wasn't me that caused that): The download link on the home page does have transparency:
Author   PhilDulac