Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
How to change the distance of components so that they do not overlap?

I would like to change the distance of the components (textfield and button) so that they do not overlap but there is a space between them and I do not know how to do this.

I would like to at least add 1-2 spaces between the fieldtext and the button

Here's how it looks:

image

code:

import * as React from 'react';
import TextField from '@mui/material/TextField';
import { Box, Paper, Button} from '@mui/material';

export default function Student() {
    const paperStyle={padding:'50px 20px', width:600, margin:"20px auto"}
    const[name, setName]=React.useState('')
    const[address, setAddress]=React.useState('')
  return (
    <Box
    
      component="form"
      sx={{
        '& > :not(style)': { m: 1, },
      }}
      noValidate
      autoComplete="off"
    >
                <Paper elevation={3} style={paperStyle}>
                    <h1 style={{color:"blue"}}><u>text</u></h1>
      <TextField id="outlined-basic" label="Name" variant="outlined" fullWidth 
      value={name}
      onChange={(e)=>setName(e.target.value)}
      />
      <TextField id="outlined-basic" label="Address" variant="outlined" fullWidth
        value={address}
        onChange={(e)=>setAddress(e.target.value)}
      />
      <Button variant="outlined">Primary</Button>
      {name}
      {address}
      </Paper>
    </Box>
  );
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

that sx prop on your Box would add the margin between the elements:

sx={{
  "& > :not(style)": { m: 1 }
}}

but the > limits it to only form elements directly inside the Box but because you added the Paper the css selector does not catch anymore.

the easyest thing would be to just more that sx prop from the Box to the Paper

Here is a working example: https://codesandbox.io/s/romantic-rubin-80o3d2?file=/src/App.js

about 4 years ago · Juan Pablo Isaza Report

0

Maybe style={{ bottomGap: 10 }} to both TextField components?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!