Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Textfields inside the .map are not lined side by side

So the text fields of name and quantity are not side by side or not in one row after I added the .map. Initially, these two text fields would show in one row, after the .map, it would not be in one row anymore.

<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
 {colorList.map((singleColor, index) => (
        <div key={index}>
          <Grid item xs={6}>
            <TextField
              label="name"
              name="name"
              type="text"
              id="name"
              required
              
            />
          </Grid>

          <br />

          <Grid item xs={6}>
            <TextField
              label="qty"
              name="qty"
              type="text"
            />
          </Grid>
        </div>
      ))}
  
</Grid>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This might work:

       <div className="row" key={index}>
          <Grid className="gridRow" item xs={6}>
            <TextField
              label="name"
              name="name"
              type="text"
              id="name"
              required
            />
          </Grid>

          <br />

          <Grid className="gridRow" item xs={6}>
            <TextField
              label="qty"
              name="qty"
              type="text"
            />
          </Grid>
        </div>

and your css classes should be like this:

.row {
   display: flex;
}

.gridRow {
   display: inline-block;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading