I want to center the label and helper text in the middle of the Textfield. I got it working with adding a padding to MuiInputLabel-root. But this is not responsive on other screen sizes (Textfield changes size and the label isnt in the center anymore). I have tried using textAlign: 'center' but it doesnt work.
-
Currently I have the Textfield with label on the left: Current
-
I want to center the label and eventually helper Text too: Expected
-
Currently when focused paddingLeft is set to 0 again: Focused
const StyledTextField = styled(TextField)({
'& .MuiInputLabel-root': {
paddingLeft: '85px',
},
'& label.Mui-focused': {
color: '#000000',
paddingLeft: '0px',
},
<StyledTextField
helperText="Privacy Policy "
InputProps={{
inputProps: {
style: { textAlign: 'center' },
},
}}
margin="normal"
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
sx={{
m: 1,
}}
/>