If you want to update modal backdrop you could use CSS like:

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

If you want to change modal background then use:

<Modal className="my-modal" show={show}>

and define in CSS:

.my-modal .modal-content {
  background-color: red;
}
Answer from tarzen chugh on Stack Overflow
🌐
React-bootstrap
react-bootstrap.github.io › react-overlays › api › Modal
Modal
The Modal offers a few helpful features over using just a <Portal/> component and some styles: Manages dialog stacking when one-at-a-time just isn't enough. Creates a backdrop, for disabling interaction below the modal.
🌐
MDBootstrap
mdbootstrap.com › standard › modal backdrop
React Bootstrap 5 Modal Backdrop - free examples & tutorial
import React, { useState } from "react"; import { MDBBtn, MDBModal, MDBModalDialog, MDBModalContent, MDBModalHeader, MDBModalTitle, MDBModalBody, MDBModalFooter, MDBContainer, } from "mdb-react-ui-kit"; export default function App() { const [noBackdropModal, setNoBackdropModal] = useState(false); const toggleShow = () => setNoBackdropModal(!noBackdropModal); return ( <MDBContainer className="p-5"> <MDBBtn onClick={toggleShow}>Launch static backdrop modal</MDBBtn> <MDBModal backdrop={false} tabIndex="-1" show={noBackdropModal} setShow={setNoBackdropModal} > <MDBModalDialog> <MDBModalContent> <M
🌐
React Bootstrap
react-bootstrap.netlify.app › modals
Modals | React Bootstrap
When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it. ... I will not close if you click outside me. Do not even try to press ... A Modal can also be without an animation. For that set the animation prop to false. ... The Modal Header, Title, Body, and Footer components are available as static properties the <Modal/> component, but you can also, import them directly like: require("react-bootstrap/ModalHeader").
🌐
npm
npmjs.com › package › react-bootstrap-modal
react-bootstrap-modal - npm
September 24, 2018 - The main Modal Component. show: Boolean(default false) make the Modal visible or hidden · backdrop: Enum<'static', true, false>(default true) - Should the modal render a backdrop overlay.
      » npm install react-bootstrap-modal
    
Published   Sep 24, 2018
Version   4.2.0
Author   Jason Quense
🌐
npm
npmjs.com › package › @mdbootstrap › react-modal-backdrop
@mdbootstrap/react-modal-backdrop - npm
August 31, 2022 - React Backdrop options for a responsive popup with Bootstrap 5. Prevent close on click outside with static backdrop, remove backdrop, enable interactivity & more.. Latest version: 1.0.0, last published: 3 years ago. Start using @mdbootstrap/react-modal-backdrop in your project by running `npm ...
      » npm install @mdbootstrap/react-modal-backdrop
    
Published   Aug 31, 2022
Version   1.0.0
Author   MDBootstrap
🌐
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
October 7, 2016 - The problem that I have is that modal-backdrop is not enclosed to the division that gets the id of the modal:
Author   nicotsou
🌐
MDBootstrap
mdbootstrap.com › standard › modal
React Modal with Bootstrap - free examples & tutorial
// Variables for modal free $modal-inner-padding: $spacer; $modal-footer-margin-between: 0.5rem; $modal-dialog-margin: 0.5rem; $modal-dialog-margin-y-sm-up: 1.75rem; $modal-title-line-height: $line-height-base; $modal-content-color: null; $modal-content-bg: $white; $modal-content-border-color: var(--#{$prefix}border-color-translucent); $modal-content-border-width: $border-width; $modal-content-inner-border-radius: subtract( $modal-content-border-radius, $modal-content-border-width ); $modal-content-box-shadow-xs: $box-shadow-sm; $modal-content-box-shadow-sm-up: $box-shadow; $modal-backdrop-bg:
🌐
Bootstrap
getbootstrap.com › docs › 4.4 › components › modal
Modal · Bootstrap
Call a modal with id myModal with a single line of JavaScript: ... Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-backdrop="".
Find elsewhere
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › components › modal
Modal · Bootstrap v5.0
$modal-inner-padding: $spacer; $modal-footer-margin-between: .5rem; $modal-dialog-margin: .5rem; $modal-dialog-margin-y-sm-up: 1.75rem; $modal-title-line-height: $line-height-base; $modal-content-color: null; $modal-content-bg: $white; $modal-content-border-color: rgba($black, .2); $modal-content-border-width: $border-width; $modal-content-border-radius: $border-radius-lg; $modal-content-inner-border-radius: subtract($modal-content-border-radius, $modal-content-border-width); $modal-content-box-shadow-xs: $box-shadow-sm; $modal-content-box-shadow-sm-up: $box-shadow; $modal-backdrop-bg: $black;
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › react-bootstrap-modal-component
React-Bootstrap Modal Component - GeeksforGeeks
March 7, 2024 - backdropClassName: It is used to add an optional extra class name to .modal-backdrop · centered: It is used to vertically center the Dialog which is open in the window. container: It is the container attribute, and it is of type any. aria-labelledby: It is the aria-labelledby attribute, and it is of type any. contentClassName: It is used to add an optional extra class name to .modal-content
🌐
Netlify
react-bootstrap-v3.netlify.app › components › modal
Components
/** * You will want to include this bit of css * * .modal-container { * position: relative; * } * .modal-container .modal, .modal-container .modal-backdrop { * position: absolute; * } */ class Trigger extends React.Component { constructor(props, context) { super(props, context); this.handleHide = this.handleHide.bind(this); this.state = { show: false }; } handleHide() { this.setState({ show: false }); } render() { return ( <div className="modal-container" style={{ height: 200 }}> <Button bsStyle="primary" bsSize="large" onClick={() => this.setState({ show: true })} > Launch contained modal </B
🌐
GitHub
github.com › react-bootstrap › react-bootstrap › issues › 2135
Multiple modal, backdrop z-index · Issue #2135 · react-bootstrap/react-bootstrap
August 11, 2016 - The z-index of all backdrop is same (1040), where, it should be above the first or previous modal. Reproducible example: https://jsfiddle.net/yrd03t24/ Also, is there a way to add class to backdrop div? I am happy to contribute. Is there...
Author   Vivekbhusal
Top answer
1 of 12
103

I was recently looking for a nice solution to this without adding React-Bootstrap to my project (as Bootstrap 4 is about to be released).

This is my solution: https://jsfiddle.net/16j1se1q/1/

let Modal = React.createClass({
    componentDidMount(){
        $(this.getDOMNode()).modal('show');
        $(this.getDOMNode()).on('hidden.bs.modal', this.props.handleHideModal);
    },
    render(){
        return (
          <div className="modal fade">
            <div className="modal-dialog">
              <div className="modal-content">
                <div className="modal-header">
                  <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  <h4 className="modal-title">Modal title</h4>
                </div>
                <div className="modal-body">
                  <p>One fine body&hellip;</p>
                </div>
                <div className="modal-footer">
                  <button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
                  <button type="button" className="btn btn-primary">Save changes</button>
                </div>
              </div>
            </div>
          </div>
        )
    },
    propTypes:{
        handleHideModal: React.PropTypes.func.isRequired
    }
});



let App = React.createClass({
    getInitialState(){
        return {view: {showModal: false}}
    },
    handleHideModal(){
        this.setState({view: {showModal: false}})
    },
    handleShowModal(){
        this.setState({view: {showModal: true}})
    },
    render(){
    return(
        <div className="row">
            <button className="btn btn-default btn-block" onClick={this.handleShowModal}>Open Modal</button>
            {this.state.view.showModal ? <Modal handleHideModal={this.handleHideModal}/> : null}
        </div>
    );
  }
});

React.render(
   <App />,
    document.getElementById('container')
);

The main idea is to only render the Modal component into the React DOM when it is to be shown (in the App components render function). I keep some 'view' state that indicates whether the Modal is currently shown or not.

The 'componentDidMount' and 'componentWillUnmount' callbacks either hide or show the modal (once it is rendered into the React DOM) via Bootstrap javascript functions.

I think this solution nicely follows the React ethos but suggestions are welcome!

2 of 12
65

You can use React-Bootstrap (https://react-bootstrap.github.io/components/modal). There is an example for modals at that link. Once you have loaded react-bootstrap, the modal component can be used as a react component:

var Modal = ReactBootstrap.Modal;

can then be used as a react component as <Modal/>.

For Bootstrap 4, there is react-strap (https://reactstrap.github.io). React-Bootstrap only supports Bootstrap 3.

🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Working with Bootstrap's Modals in React | Pluralsight
November 26, 2019 - import React from "react"; import ReactDOM from "react-dom"; import Modal from "react-bootstrap/Modal"; import ModalBody from "react-bootstrap/ModalBody"; import ModalHeader from "react-bootstrap/ModalHeader"; import ModalFooter from "react-bootstrap/ModalFooter"; import ModalTitle from "react-bootstrap/ModalTitle"; const App = () => { return ( <Modal show={true}> <ModalHeader> <ModalTitle>Hi</ModalTitle> </ModalHeader> <ModalBody>asdfasdf</ModalBody> <ModalFooter>This is the footer</ModalFooter> </Modal> ); }; const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement);
🌐
Ordinarycoders
ordinarycoders.com › blog › article › react-bootstrap-modal
How to Make A React Bootstrap Modal
A Bootstrap modal is a component that's positioned over everything else in the HTML document. Bootstrap modals by default place a transparent, darkened background over all elements behind the modal. React is an open-source JavaScript library ...
🌐
npm
npmjs.com › package › react-modal-bootstrap
react-modal-bootstrap - npm
Modal component for React with bootstrap style. ... You can set custom styles vie backDropStyles, dialogStyles prop.
      » npm install react-modal-bootstrap
    
Published   Mar 21, 2017
Version   1.1.1
Author   Minh Tran
🌐
GitHub
github.com › react-bootstrap › react-bootstrap › issues › 5732
missing `backdrop` attribute on `ModalProps` when using typescript · Issue #5732 · react-bootstrap/react-bootstrap
March 22, 2021 - Describe the bug I am using react-bootstrap with typescript. I want to prevent modal component from being clicked outside its own element, so I just set backdrop props value into static. Unfortunately, backdrop wasn't show when using vsc...
Author   achmadk
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal backdrop is not working - Material Design for Bootstrap
Expected behavior The modal backdrop should allow user to click on the body of the component Actual behavior Not able to click on the body of the component except on the m
🌐
GitHub
github.com › react-bootstrap › react-overlays › issues › 87
How to get more control over backdrop (I want to put an x mark on it) · Issue #87 · react-bootstrap/react-overlays
May 9, 2016 - @reywright its right here: https://github.com/react-bootstrap/react-overlays/blob/v0.6.12/src/Modal.js#L314 ... let backdropElement = (<div className="hey"></div>); return ( <Modal show={open} style={modalStyle} renderBackdrop={backdropElement} >)