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

444
Views
How can I verically center InputLabel inside MUI Grid item?

I want to vertically center InputLabel inside MUI Grid item. I tried following:

import { FormControl, Grid, Input, InputLabel, TextField } from "@mui/material";

export default function App() {
  return (
    <Grid container>
      <Grid item xs={2}>
        <InputLabel htmlFor="name-input">First Name: </InputLabel>
      </Grid>
      <Grid item xs={10}>
        <TextField size="small"></TextField>
      </Grid>
      <Grid item xs={2}>
        <InputLabel sx={{ verticalAlign: "middle" }} htmlFor="name-input">
          First Name:{" "}
        </InputLabel>
      </Grid>
      <Grid item xs={10}>
        <TextField size="small"></TextField>
      </Grid>
    </Grid>
  );
}

But its not getting vertically aligned:

enter image description here

codesandbox link

Note that setting sx={{ verticalAlign: "middle" }} in second InputLabel also doesnt help.

How one should (possibly ideally) vertically center InputLabel (or any other control) inside Grid item?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I add

display: flex;
align-items: center;

to the grid item divs it works.

I find this a useful flexbox explainer: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

I've added it to your sandbox here: https://codesandbox.io/s/peaceful-pascal-3rpokb?file=/src/App.js

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!