ReactStrap: Rows and columns causing components to stack on top of each other

When I opt not to utilize Row and Col:

<FormGroup>
                          <InputGroup>
                            <InputGroupAddon addonType="prepend">
                              <InputGroupText>
                                Client's Email Address
                              </InputGroupText>
                            </InputGroupAddon>
                            <Input
                              type="email"
                              id="email"
                              name="email"
                              value={this.state.email}
                              onChange={this.onChange}
                              required
                              disabled={
                                this.state.isClientInformationFieldsDisabled
                              }
                            />
                            <InputGroupAddon addonType="append">
                              <InputGroupText>
                                <i className="fa fa-asterisk"></i>
                              </InputGroupText>
                              <Button
                                color="secondary"
                                onClick={this.onClearClientFields}
                                disabled={
                                  this.state.isClientClearFieldsButtonDisabled
                                }
                              >
                                X
                              </Button>
                            </InputGroupAddon>
                            <Button
                              color="primary"
                              onClick={this.onValidateEmailClient}
                              disabled={
                                this.state.isEmailValidateButtonDisabled
                              }
                              style={{ fontWeight: "bold" }}
                            >
                              Validate Email Address
                            </Button>
                          </InputGroup>
                        </FormGroup>

https://i.sstatic.net/dLzPY.png

When I make use of Row and Col:

 <FormGroup>
  <InputGroup>
    <Row>
      <Col lg={"12"}>
        <InputGroupAddon addonType="prepend">
          <InputGroupText>
            Client's Email Address
          </InputGroupText>
        </InputGroupAddon>
        <Input
          type="email"
          id="email"
          name="email"
          value={this.state.email}
          onChange={this.onChange}
          required
          disabled={
            this.state.isClientInformationFieldsDisabled
          }
        />
        <InputGroupAddon addonType="append">
          <InputGroupText>
            <i className="fa fa-asterisk"></i>
          </InputGroupText>
          <Button
            color="secondary"
            onClick={this.onClearClientFields}
            disabled={
              this.state
                .isClientClearFieldsButtonDisabled
            }
          >
            X
          </Button>
        </InputGroupAddon>
        <Button
          color="primary"
          onClick={this.onValidateEmailClient}
          disabled={
            this.state.isEmailValidateButtonDisabled
          }
          style={{ fontWeight: "bold" }}
        >
          Validate Email Address
        </Button>
      </Col>
    </Row>
  </InputGroup>
</FormGroup>

The issue arises when I attempt to regulate the width of form elements by employing both Col and the lg,md properties. Initially, I suspected that using Row and Col might disrupt the layout of the FormGroup. Therefore, I provided it with maximum width to observe the behavior as displayed in the result above.

I fail to comprehend why the elements stack on top of each other despite the entire Form remaining at a maximum width of 12. Consequently, there should be no alteration in the layout structure.

This predicament surfaced when I endeavored to introduce an additional button into the Form, causing a cluttered appearance. Subsequently, I resorted to utilizing the Row and Col components to maintain precise control over each element within the Form.

Consequently, the outcome turned out as depicted.

Can anyone elucidate this observed behavior?


EDIT 1: I tried implementing the solution proposed by Dimitar Spassov with another input group:

   <FormGroup>
                              <Container fluid={true}>
                                <Row>
                                  <Col md={"2"} >
                                    <InputGroup >
                                      <InputGroupAddon addonType="prepend">
                                        <InputGroupText>
                                          Phone Number
                                        </InputGroupText>
                                      </InputGroupAddon>
                                    </InputGroup>
                                  </Col>
                                  <Col md={"9"}>
                                    <InputGroup>
                                      <IntlTelInput
                                        containerClassName="intl-tel-input"
                                        inputClassName="form-control"
                                        style={{ width: "100%" }}
                                        block
                                      />
                                    </InputGroup>
                                  </Col>
                                  <Col md={"1"}>
                                    <InputGroup style={{ height: "100%" }}>
                                      <InputGroupAddon
                                        // style={{ height: "100%" }}
                                        addonType="append"
                                      >
                                        <InputGroupText
                                        // style={{ height: "100%" }}
                                        >
                                          <i className="fa fa-asterisk"></i>
                                        </InputGroupText>
                                      </InputGroupAddon>
                                    </InputGroup>
                                  </Col>
                                </Row>
                              </Container>
                            </FormGroup>

https://i.sstatic.net/jp4i0.png

Now, the current concern revolves around the presence of padding between distinct input groups within the phone number form. My aim is to replicate the format similar to the one exhibited in the form underneath it. So far, I haven't discovered an effective method to navigate this obstacle.

fluid={true}

Hence, inserted the aforementioned segment to eliminate the external padding of the Container (as explained here). Much to my dismay, this adjustment delivered no discernible change. Even after consulting the documentation for InputGroup to understand how to eradicate the extraneous paddings yielded no beneficial results.

To address this dilemma, I made attempts to leverage Bootstrap utility classes aiming to obliterate any default margins or padding, yet regrettably, these efforts proved futile:

 <InputGroup className="ml-0 mr-0 pl-0 pr-0">
                                  <InputGroupAddon addonType="prepend">
                                    <InputGroupText>
                                      Phone Number
                                    </InputGroupText>
                                  </InputGroupAddon>
                                </InputGroup>

Answer №1

Placing Row and Col inside of the InputGroup may not be the most suitable option. Instead, consider creating multiple InputGroup elements and enclosing them within individual Col components. This approach will give you better control over the width of each element.

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

Encountering an issue: "An error has occurred - ReferenceError: window is not defined"

Initially, everything was functioning as expected. However, out of nowhere, an error popped up saying "ReferenceError: window is not defined". This issue occurred suddenly while I was using Next.js, and the problematic code resides within a custom react ho ...

HTML text-indent is a way to add extra space to

I cannot understand why my text is not indenting properly. At the very bottom left corner, the "Educational Specifications" text is enclosed within a p element as follows: <p style="text-indent: 3em">Educational Specifications</p> Why doesn& ...

Using React to manage elements with duplicate refs

Can someone help me with this issue I'm facing? let list = storage.map((element, index, array) => { return ( <li key={index} className="list-element"> <div className="title-wrapper" onMouseEnter={this.handleMouseEnter}> ...

What sets SVG and CSS3 animations apart and where do they overlap?

Sencha Animator relies on CSS3 animations as its primary animation tool. RaphaelJS, on the other hand, favors SVG animations for its visual effects. I'm curious about the parallels and distinctions between SVG and CSS3 animations. Is either one a s ...

Tips for deciding on the appropriate CSS for an Angular 6 navbar component

I am currently working on an angular 6 application where users are assigned different roles that require distinct styling. Role 1 uses Stylesheet 1, while Role 2 uses Stylesheet 2. The Navbar component is a crucial part of the overall layout structure of ...

Tips for transferring information between two HTML pages

Looking for some advice here. I'm in the process of creating a website for my record store using HTML5. On one page (store.html), I plan to showcase all the albums with a Buy Now button below each album that links to buy.html <div class="item got ...

Using the Fetch API in React to send a CSRF token to Django server

Currently, I am working on sending the csrf token that was generated Here is how the csrftoken generation occurs: const [cr , setCR] = useState('') const getcsrf = async () => { await fetch('http://localhost:8000/auth/gett ...

Attempting to submit a form containing multiple fields that share the same name as an array

I am attempting to submit a form with fields that function as entries in a table For clarity, here is an example: <form method="post"> <table> <tr> <td><label>Name:</label></td> ...

The issue with jQuery trigger not passing the value of a radio button has been

I have implemented a radio button (Yes, No) and an input text box on my form. If the user selects 'No', the input field is disabled and jQuery triggers a change event for AJAX form submission. $('#form-id').change(function(){ .... }); ...

Customizing the Navigation Border-Bottom in WordPress

Currently, I am working on a project with this website. My main focus is on removing the border-bottom in the navigation bar for the last two right navigation points which are "DE" and "FR". Despite trying various CSS solutions, such as: #menu-item-394 { ...

Seeking advice on resolving issues when utilizing a router in React and encountering errors

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default ...

Preserving the most recent choice made in a dropdown menu

Just started with angular and facing an issue saving the select option tag - the language is saved successfully, but the select option always displays English by default even if I select Arabic. The page refreshes and goes back to English. Any assistance o ...

Can you explain the distinction between an AJAX post request and a form post request?

When dealing with post requests on the server side, I utilize Flask. The same code can handle both types of requests. However, on the client side, an AJAX request prevents the browser from refreshing the entire page, unlike a form submission. What is the ...

Ben Kamens has developed a new feature in jQuery Menu Aim where the sub menu will not reappear once it

While exploring Ben Kemens’ jquery-menu-aim, I came across a demonstration on codepen. The code on codepen allows smooth transition from the main menu to the sub menu, but if you move away completely, the submenu remains visible and doesn't disappe ...

Send an identifier as part of the URL to an HTML page that is accessed through a different URL

I am working on a template that is accessed via the URL /add and it contains multiple registration pages developed using ReactJS. Within the add.html page, which is called by the URL /add, there is an image upload form also implemented in ReactJS. This for ...

The top content above the Bootstrap navbar fails to remain fixed in place

Seeking assistance with a Bootstrap 4 navbar and header setup. The goal is to have the navbar stick to the top while making the header disappear on scroll. In my functions.php file, I've enqueued Jquery for this project. Below is the CSS found in st ...

Guide to deploying a React application using Material-UI and react-router

I've successfully built an application using React, Material-UI, and react-router. Below is the content of my complete package.json: { "name": "trader-ui", "version": "0.1.0", "private": true, "dependencies": { "@material-ui/core": "^3.2. ...

What exactly does npm link do and how can it be implemented in React JS projects?

I'm diving into React JS and Node JS for the first time, but I'm struggling to grasp the concept of npm link and how it fits into React JS Projects. Even after reading the npm documentation, I could use a clear explanation and example to help me ...

Guide on passing a JSON body as a string in a PUT API request using Fetch in a React.js application

How can I pass a JSON body as a string in a FETCH PUT API in React JS? I am attempting to add 20 to the Balance like this: Balance: details[0].Balance.toString() + 20, but it is not working as expected. I want the entire result to be a string. Any assista ...

Merging Two Arrays to Form a Single Array in React

Let's consider the following arrays: const headerArray = ["h1","h2","h3"]; const dataArray=[["a1","a2","a3"],["b1","b2","b3"]]; I have a requirement to merge th ...