Home > Net >  Change MUI Text color of TextField Component
Change MUI Text color of TextField Component

Time:10-05

So the code is this:

                        <TextField
                          required
                          id="outlined-select-currency"
                          select
                          label="Client Type"
                          value={currency}
                          onChange={handleChange}
                          sx={{ '& input' : {color: 'white'}, '& label.Mui-focused': { color: 'white' }, '& label' : {color: 'white'} }}
                        >
                          {currencies.map((option) => (
                            <MenuItem key={option.value} value={option.value}
                            >
                              {option.label}
                            </MenuItem>
                          ))}
                        </TextField>

and the result is this:

enter image description here enter image description here

But when you select from the dropdown you get this:

enter image description here

Does anyone know what class should I override to change the text color? (on other the sx{} work just fine, but here using the it doesn't.

enter image description here

Thanks for the help.

CodePudding user response:

The class name is .MuiInputBase-input on which you can set color: "yourColor"

<TextField             
    sx={{ '& .MuiInputBase-input': { color: 'white' } }}
/>
  • Related