Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

382
Visualizações
MUI DatePicker default textfield cannot be customized with different font color and size

I am having an issue while using MUI DatePicker . I am not being able to customize the font color & font size of the date. My code is :

const DateSettings = () => {
  const [value, setValue] = React.useState<Date | null>();

  const handleChange = (newValue: Date | null) => {
    setValue(newValue);
  };
  return (
    <Box>
      <LocalizationProvider dateAdapter={DateAdapter}>
        <Stack spacing={3}>
            <MobileDatePicker
              label="Date mobile"
              inputFormat="MM/dd/yyyy"
              value={value}
              onChange={handleChange}
              components={{ OpenPickerIcon: CalendarIcon }}
              renderInput={(params) => (
                <TextField  {...params} />
              )}
            />
        </Stack>
      </LocalizationProvider>
    </Box>
  );
};

export default DateSettings;

I have tried adding style to the textfield using sx prop as usual. It changes the background color but doesn't change the font color & font size if I use this code block:

renderInput={(params) => (
                <TextField sx={{backgroundColor:'red',color:'white'}} {...params} />
              )}

settings image

I have also tried custom style like this, but still the same!

const useStyles = makeStyles({
  root: {
    background: "red",
    border: 0,
    borderRadius: 3,   
    color: "white",
  },
});

const DateSettings = () => {
  const classes = useStyles();
 
  return (
    <Box>
      <LocalizationProvider dateAdapter={DateAdapter}>
        <Stack spacing={3}>
            <MobileDatePicker
              className={classes.root}
              inputFormat="MM/dd/yyyy"
              value={value}
              onChange={handleChange}
              components={{ OpenPickerIcon: CalendarIcon }}
              renderInput={(params) => (
                <TextField  {...params} />
              )}
            />
         </Stack>
      </LocalizationProvider>
    </Box>
  );
};

export default DateSettings;

Is there any other way to change it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

All you had to do was inspect the text, copy the applicable classname and apply classes.root directly to .

enter image description here

const useStyles = makeStyles({
  root: {
    "& .MuiOutlinedInput-input": {
      border: 0,
      borderRadius: 3,
      color: "red",
      fontSize: 24
    }
  }
});

const DateSettings() {
  const classes = useStyles();
  const [value, setValue] = useState(Date | (null > null));

  return (
    <Box>
      <LocalizationProvider dateAdapter={AdapterDateFns}>
        <Stack spacing={3}>
          <MobileDatePicker
            inputFormat="MM/dd/yyyy"
            value={value}
            onChange={handleChange}
            components={{ OpenPickerIcon: CalendarIcon }}
            renderInput={(params) => <TextField className={classes.root} {...params} />}
          />
        </Stack>
      </LocalizationProvider>
    </Box>
  );
}

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda