Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MUI V5 Textfield - Change border color?

Tags:

material-ui

using Material UI V5 and i can't change the border color of my TextField with the sx prop.

Changing the color of the label and input works fine, but not with border color.

<TextField
        sx={{ 
          input: { color: 'white' } ,
          label: {color: 'white'},
          borderColor: 'white',
          border: {color: 'white'},
        }}

Any ideas?

like image 539
Freddy Avatar asked Oct 18 '25 13:10

Freddy


1 Answers

The TextField is a weird one, the border is actually defined on the fieldset element. The following should style that.

<TextField 
  sx={{
    fieldset: { borderColor: "red" }
  }}

Here is a screen capture of the TextField HTML to help show the fieldset element I'm talking about. enter image description here

like image 83
jdk905 Avatar answered Oct 22 '25 08:10

jdk905



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!