Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change input text color of fluent ui TextField?

I simply want to change the input text color to another one.
Component example is:

<TextField
     styles={{
       fieldGroup: {
         borderRadius: 0,
         border: '0px solid transparent',
         background: '#F3F2F1',
       },
       input : {
         color: '#FF0000',
       }
     }}
     placeholder="---------Text----------"
  /> 

I have tried to set the color property on description, errorMessage, field, fieldGroup, icon, prefix, suffix, root, subComponentStyles, and wrapper properties of the IStyle object, but it doesn’t work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to do the following change in your code. Inside styles, instead of input use field property to change css for input text. Like this:

<TextField
        label="Fluent UI TextField"
        styles={{
          fieldGroup: {
            borderRadius: 0,
            border: "0px solid transparent",
            background: "#F3F2F1"
          },
          field: {
            color: "#FF0000"
          }
        }}
        placeholder="---------Text----------"
      />

You metioned that you already tried using the field property but it didn’t work. I believe there must be some other reason for that. You can see the full working code in the below codepen url. May be there’s something else missing in your code (if so please share more info) . Hope it helps.

Full working code at codepen – https://codepen.io/AnkitSaxena2605/pen/LYepGxp

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading