I'm using react-bootstrap modal.
How can I make only body to scroll and not all the page?
  <Modal.Dialog>
    <Modal.Header>
      <Modal.Title>Modal title</Modal.Title>
    </Modal.Header>
    <Modal.Body>One fine body...</Modal.Body>
    <Modal.Footer>
      <Button>Close</Button>
      <Button bsStyle="primary">Save changes</Button>
    </Modal.Footer>
  </Modal.Dialog>
                Bootstrap 4.3 added new built-in scroll feature to modals. This makes only the modal-body content scroll if the size of the content would otherwise make the page scroll. To use it, just add the class modal-dialog-scrollable to the same div that has the modal-dialog class.
To implement scrolling in the Popup component, do the following: Wrap the content in the ScrollView component and place it in the Popup container. Set the height and width of the ScrollView to 100% of the popup content area.
You can apply it by placing the overflow-y:scroll in the id growth inside the style tag. Notice the scroll bar on the right side of the div .
Thanks to Amit answer.
The first solution using only styles would be the following:
  <Modal.Dialog>
    <Modal.Header>
      <Modal.Title>Modal title</Modal.Title>
    </Modal.Header>
    <Modal.Body style={{
      maxHeight: 'calc(100vh - 210px)',
      overflowY: 'auto'
     }}
    >
     One fine body...
    </Modal.Body>
    <Modal.Footer>
      <Button>Close</Button>
      <Button bsStyle="primary">Save changes</Button>
    </Modal.Footer>
  </Modal.Dialog>
There is a new way to implement that behavior using the react-bootstrap itself:
<Modal
  scrollable={true}
  ....
>
  ....
</Modal>
Modal Documentation
you can add scrollable to the Modal:
<Modal scrollable={true}>
</Modal>
You can get details from the Modal docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With