What is the best way to adjust the height and width of a Modal in a react-bootstrap

I'm currently working on implementing a React Bootstrap Modal in my project. However, I am facing an issue where the dialog appears to be too small for my requirements. I would like to make it bigger, but despite completing the code, it seems that the CSS styling is not taking effect.

Below is the code snippet:

<Modal show={showModal} onHide={handleClose} className='modalSize'>
    <Modal.Body>
        <Row>
            <Col lg={6}>
                <img 
                    className
                    src= {modalData.picture}
                />
            </Col>

            <Col lg={6}>
                <h1>{modalData.name}</h1>
                <h1>{modalData.position}</h1>
            </Col>
        </Row>
    </Modal.Body>
</Modal>

CSS :

.modalSize{
    width: 100% !important;
}

Answer №1

According to the react-bootstrap documentation: Size

To specify the size of the modal, you can simply add a parameter like size="lg" as shown below

function CustomModal() {
  const [smShow, setSmShow] = useState(false);
  const [lgShow, setLgShow] = useState(false);

  return (
    <>
      <Button onClick={() => setSmShow(true)} className="me-2">
        Small Modal
      </Button>
      <Button onClick={() => setLgShow(true)}>Large Modal</Button>
      <Modal
        size="sm"
        show={smShow}
        onHide={() => setSmShow(false)}
        aria-labelledby="custom-modal-size-sm"
      >
        <Modal.Header closeButton>
          <Modal.Title id="custom-modal-size-sm">
            Small Modal
          </Modal.Title>
        </Modal.Header>
        <Modal.Body>...</Modal.Body>
      </Modal>
      <Modal
        size="lg"
        show={lgShow}
        onHide={() => setLgShow(false)}
        aria-labelledby="custom-modal-size-lg"
      >
        <Modal.Header closeButton>
          <Modal.Title id="custom-modal-size-lg">
            Large Modal
          </Modal.Title>
        </Modal.Header>
        <Modal.Body>...</Modal.Body>
      </Modal>
    </>
  );
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A visually stunning image showcase with dynamic resizing and strategically placed white spaces using the m

I'm attempting to create a responsive image gallery using the Masonry jQuery plugin, but despite reading numerous articles and forum posts on the topic, I can't seem to get it to work properly. The gallery is displaying many blank spaces. My app ...

Eliminate CSS property with Jquery

I have found that most solutions only remove the attribute setting rather than removing the attribute entirely. My goal is to switch the positioning of an element from absolute to fixed. In order to position the element correctly within its parent DIV, I ...

Can we reduce the number of classes and pseudo classes sharing the same style?

How can I condense the following CSS into a more concise LESS code? .push-nav > .active > a, .push-nav > .active > a:hover, .push-nav > .active > a:focus { background:#000; color: #fff; } Here is my attempt: .push-nav > .act ...

Text reveal animation in Framer Motion is not functioning as expected

I'm having trouble locating the issue in my code, and the text reveal feature isn't working. Interestingly, a simple animation works fine, indicating that there's no problem with the import or library: import { motion } from ...

React does not allow for images to be used as background elements

I am currently working on a web page and I have attempted to use both jpg and png images as backgrounds, but they do not seem to display on the page. import './Entrada.css' const Entrada = () => { return( <div style={{ b ...

Can anyone help me with fixing the error message 'Cannot assign to read-only property 'exports' of the object' in React?

Recently, I decided to delve into the world of React and started building a simple app from scratch. However, I have run into an issue that is throwing the following error: Uncaught TypeError: Cannot assign to read-only property 'exports' of o ...

What is causing the colored SVG to appear lighter than the intended color after using a mask to recolor it?

I have a project using VueJS where I am trying to change the color of SVGs by looping through them and using mask and rect tags. However, I am noticing that as the icon index increases, the color of the icon becomes lighter. What could be causing this issu ...

Is it possible to set a single Tailwind breakpoint that will automatically apply to all CSS styles below it?

Responsive design in Tailwind is achieved by using the following code snippet: <div className="sm: flex sm: flex-row sm: items-center"></div> It can be cumbersome to constantly include the sm: breakpoint for each CSS rule. I want ...

Troubleshooting Problems with Uploading Images through a React-Based Web Browser Interface

I'm currently working on allowing users to upload multiple images using React and then saving them to a server. One issue I've encountered is that sometimes when I click choose image, it works fine, but other times it does not. The same inconsis ...

Using Bootstrap 4 allows me to make the top navbar fixed when scrolling. Is there a way to also make another line below it fixed in normal CSS?

Is it possible to create a top-fixed navigation using the navbar in HTML? I also want to make another heading text that remains fixed even when the page is fully scrolled. I am having trouble achieving this effect. Please suggest if it can be achieved wi ...

What is the best way to ensure that only one div is toggled at a time while using the toggle class function?

$(document).ready(function(){ $("#items").children().click(function(){ $(this).toggleClass('clicked'); }); }); .clicked { background-color:red; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></s ...

Converting a child.jsp file into a modal or overlay using JavaScript: A step-by-step guide

Is it possible to call a child.jsp as a model using JavaScript? I previously accessed the child jsp using showmodaldialog and window.open() with JavaScript, but it opens in another window. I want the child jsp to appear in a modal or overlay view. Can some ...

Extracting text sizes from HTML and CSS

Struggling to extract the font size of text sections from an HTML page. Despite exploring python libraries like cssutils and beautiful-soup, my efforts have been fruitless so far. My homemade html parser only captures font sizes within the html itself, n ...

Out of the blue div, could you lend your assistance?

I have a code that displays 5 random images with corresponding text. My challenge is that I want to separate the text into another div so that I can add another function to it, while still keeping the images random with their corresponding text. <scr ...

Component that dynamically changes background images in Vue

I'm currently working on a Vue banner that requires a dynamic background, but for some reason, it's not functioning as expected. I've experimented with different methods, and using an image tag like this works: <img :src="require(`@/asse ...

Can the CSS be used to conceal the PNG image while still preserving the drop shadow effect?

I recently applied the "Filter: drop-shadow" effect to my png photo and it worked perfectly. However, I am now interested in hiding the actual png image while retaining the shadow effect. My initial attempt involved adjusting the translate and drop-shadow ...

Customize checkbox and label using jQuery

I have a scenario where I have multiple checkboxes and corresponding labels. When the answer is correct, I want to change the background color of the selected checkbox and label. <input type="checkbox" id="a" class="check-with-label" /> <label fo ...

What can be done to ensure that the a href tag is functioning as clickable?

Having an issue with my HTML and CSS code for a notification dropdown box. I am unable to click the tag, even after attempting to use JavaScript. Can't seem to figure out what's causing this problem. Any advice on how to make the tag clickable? ...

Div Boxes at the Center

I've searched extensively for a solution to my unique problem, but haven't been able to find one that fits. I have 4 div boxes with a max width of 50% and a min width of 400px. When the site is viewed on a smaller screen, I want the boxes to alig ...

CSS creates captivating image hover transitions with span elements

<a href=""><img src=""><span>content</span></a> When I hover over the image, the content within the span appears using relative positioning with display set to none and absolute positioning in the span tag. My query is regard ...