Material UI changing the color of inputs floating label












6















I want to change the color of a floating title for Material-UI's textfield.



As stated in documentation, I pass the object color as floatingLabelStyle:



<TextField floatingLabelStyle={{color: somecolor }} />


But this applies to both states of the label - hovering above the input and on the input while out of focus, when it's supposed to be grey.



I guess that I'm overwriting some kind of CSS transition, but have no idea how to make it work. Any suggestions?










share|improve this question




















  • 1





    code or link perhaps?

    – Bruno Kos
    Mar 3 '16 at 19:48











  • <TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

    – Łukasz Smoczyński
    Mar 3 '16 at 19:53
















6















I want to change the color of a floating title for Material-UI's textfield.



As stated in documentation, I pass the object color as floatingLabelStyle:



<TextField floatingLabelStyle={{color: somecolor }} />


But this applies to both states of the label - hovering above the input and on the input while out of focus, when it's supposed to be grey.



I guess that I'm overwriting some kind of CSS transition, but have no idea how to make it work. Any suggestions?










share|improve this question




















  • 1





    code or link perhaps?

    – Bruno Kos
    Mar 3 '16 at 19:48











  • <TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

    – Łukasz Smoczyński
    Mar 3 '16 at 19:53














6












6








6








I want to change the color of a floating title for Material-UI's textfield.



As stated in documentation, I pass the object color as floatingLabelStyle:



<TextField floatingLabelStyle={{color: somecolor }} />


But this applies to both states of the label - hovering above the input and on the input while out of focus, when it's supposed to be grey.



I guess that I'm overwriting some kind of CSS transition, but have no idea how to make it work. Any suggestions?










share|improve this question
















I want to change the color of a floating title for Material-UI's textfield.



As stated in documentation, I pass the object color as floatingLabelStyle:



<TextField floatingLabelStyle={{color: somecolor }} />


But this applies to both states of the label - hovering above the input and on the input while out of focus, when it's supposed to be grey.



I guess that I'm overwriting some kind of CSS transition, but have no idea how to make it work. Any suggestions?







javascript css reactjs material-ui






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 3 '16 at 22:28









Andrew Myers

2,07651932




2,07651932










asked Mar 3 '16 at 19:47









Łukasz SmoczyńskiŁukasz Smoczyński

3613




3613








  • 1





    code or link perhaps?

    – Bruno Kos
    Mar 3 '16 at 19:48











  • <TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

    – Łukasz Smoczyński
    Mar 3 '16 at 19:53














  • 1





    code or link perhaps?

    – Bruno Kos
    Mar 3 '16 at 19:48











  • <TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

    – Łukasz Smoczyński
    Mar 3 '16 at 19:53








1




1





code or link perhaps?

– Bruno Kos
Mar 3 '16 at 19:48





code or link perhaps?

– Bruno Kos
Mar 3 '16 at 19:48













<TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

– Łukasz Smoczyński
Mar 3 '16 at 19:53





<TextField floatingLabelStyle={{color: somecolor }} /> that's the way im trying to do it.

– Łukasz Smoczyński
Mar 3 '16 at 19:53












5 Answers
5






active

oldest

votes


















2














You should use floatingLabelFocusStyle:



const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}

<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />





share|improve this answer































    1














    You should set style of InputLabel:



    const styles = {
    floatingLabelFocusStyle: {
    color: "somecolor"
    }
    }

    <TextField
    label="Test"
    id="test"
    InputLabelProps={{
    className: classes.floatingLabelFocusStyle,
    }}
    />





    share|improve this answer































      0














      This is a bug, please raise it with them.



      Explanation



      Just went through their source code. Initially the label color is set as hintColor.



      const styles = {
      ...
      floatingLabel: {
      color: hintColor,
      pointerEvents: 'none',
      },
      ...
      }


      On focus, the color of the label is changed to focusColor from muiTheme



      if (state.isFocused) {
      styles.floatingLabel.color = focusColor;
      }


      And then overridden if any value is given



      <TextFieldLabel
      style={Object.assign(styles.floatingLabel, this.props.floatingLabelStyle)}
      ...
      >


      So your property is always overridden and thus you see the same color always.






      share|improve this answer































        0














        This does the tick



          InputLabelProps={{
        style: { color: '#fff' },
        }}





        share|improve this answer































          -1














          Here is one css line to change the color



          .mat-focused{ color:red!important;}





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35781631%2fmaterial-ui-changing-the-color-of-inputs-floating-label%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You should use floatingLabelFocusStyle:



            const styles = {
            floatingLabelFocusStyle: {
            color: "somecolor"
            }
            }

            <TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />





            share|improve this answer




























              2














              You should use floatingLabelFocusStyle:



              const styles = {
              floatingLabelFocusStyle: {
              color: "somecolor"
              }
              }

              <TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />





              share|improve this answer


























                2












                2








                2







                You should use floatingLabelFocusStyle:



                const styles = {
                floatingLabelFocusStyle: {
                color: "somecolor"
                }
                }

                <TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />





                share|improve this answer













                You should use floatingLabelFocusStyle:



                const styles = {
                floatingLabelFocusStyle: {
                color: "somecolor"
                }
                }

                <TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 18 '16 at 23:06









                Jan Franz PalngipangJan Franz Palngipang

                2,4211622




                2,4211622

























                    1














                    You should set style of InputLabel:



                    const styles = {
                    floatingLabelFocusStyle: {
                    color: "somecolor"
                    }
                    }

                    <TextField
                    label="Test"
                    id="test"
                    InputLabelProps={{
                    className: classes.floatingLabelFocusStyle,
                    }}
                    />





                    share|improve this answer




























                      1














                      You should set style of InputLabel:



                      const styles = {
                      floatingLabelFocusStyle: {
                      color: "somecolor"
                      }
                      }

                      <TextField
                      label="Test"
                      id="test"
                      InputLabelProps={{
                      className: classes.floatingLabelFocusStyle,
                      }}
                      />





                      share|improve this answer


























                        1












                        1








                        1







                        You should set style of InputLabel:



                        const styles = {
                        floatingLabelFocusStyle: {
                        color: "somecolor"
                        }
                        }

                        <TextField
                        label="Test"
                        id="test"
                        InputLabelProps={{
                        className: classes.floatingLabelFocusStyle,
                        }}
                        />





                        share|improve this answer













                        You should set style of InputLabel:



                        const styles = {
                        floatingLabelFocusStyle: {
                        color: "somecolor"
                        }
                        }

                        <TextField
                        label="Test"
                        id="test"
                        InputLabelProps={{
                        className: classes.floatingLabelFocusStyle,
                        }}
                        />






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Sep 17 '18 at 15:10









                        BorzhBorzh

                        3,12813047




                        3,12813047























                            0














                            This is a bug, please raise it with them.



                            Explanation



                            Just went through their source code. Initially the label color is set as hintColor.



                            const styles = {
                            ...
                            floatingLabel: {
                            color: hintColor,
                            pointerEvents: 'none',
                            },
                            ...
                            }


                            On focus, the color of the label is changed to focusColor from muiTheme



                            if (state.isFocused) {
                            styles.floatingLabel.color = focusColor;
                            }


                            And then overridden if any value is given



                            <TextFieldLabel
                            style={Object.assign(styles.floatingLabel, this.props.floatingLabelStyle)}
                            ...
                            >


                            So your property is always overridden and thus you see the same color always.






                            share|improve this answer




























                              0














                              This is a bug, please raise it with them.



                              Explanation



                              Just went through their source code. Initially the label color is set as hintColor.



                              const styles = {
                              ...
                              floatingLabel: {
                              color: hintColor,
                              pointerEvents: 'none',
                              },
                              ...
                              }


                              On focus, the color of the label is changed to focusColor from muiTheme



                              if (state.isFocused) {
                              styles.floatingLabel.color = focusColor;
                              }


                              And then overridden if any value is given



                              <TextFieldLabel
                              style={Object.assign(styles.floatingLabel, this.props.floatingLabelStyle)}
                              ...
                              >


                              So your property is always overridden and thus you see the same color always.






                              share|improve this answer


























                                0












                                0








                                0







                                This is a bug, please raise it with them.



                                Explanation



                                Just went through their source code. Initially the label color is set as hintColor.



                                const styles = {
                                ...
                                floatingLabel: {
                                color: hintColor,
                                pointerEvents: 'none',
                                },
                                ...
                                }


                                On focus, the color of the label is changed to focusColor from muiTheme



                                if (state.isFocused) {
                                styles.floatingLabel.color = focusColor;
                                }


                                And then overridden if any value is given



                                <TextFieldLabel
                                style={Object.assign(styles.floatingLabel, this.props.floatingLabelStyle)}
                                ...
                                >


                                So your property is always overridden and thus you see the same color always.






                                share|improve this answer













                                This is a bug, please raise it with them.



                                Explanation



                                Just went through their source code. Initially the label color is set as hintColor.



                                const styles = {
                                ...
                                floatingLabel: {
                                color: hintColor,
                                pointerEvents: 'none',
                                },
                                ...
                                }


                                On focus, the color of the label is changed to focusColor from muiTheme



                                if (state.isFocused) {
                                styles.floatingLabel.color = focusColor;
                                }


                                And then overridden if any value is given



                                <TextFieldLabel
                                style={Object.assign(styles.floatingLabel, this.props.floatingLabelStyle)}
                                ...
                                >


                                So your property is always overridden and thus you see the same color always.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Mar 3 '16 at 20:55









                                Bharath RajaBharath Raja

                                18911




                                18911























                                    0














                                    This does the tick



                                      InputLabelProps={{
                                    style: { color: '#fff' },
                                    }}





                                    share|improve this answer




























                                      0














                                      This does the tick



                                        InputLabelProps={{
                                      style: { color: '#fff' },
                                      }}





                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        This does the tick



                                          InputLabelProps={{
                                        style: { color: '#fff' },
                                        }}





                                        share|improve this answer













                                        This does the tick



                                          InputLabelProps={{
                                        style: { color: '#fff' },
                                        }}






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jan 1 at 19:59









                                        Malte Schulze-BoeingMalte Schulze-Boeing

                                        38529




                                        38529























                                            -1














                                            Here is one css line to change the color



                                            .mat-focused{ color:red!important;}





                                            share|improve this answer




























                                              -1














                                              Here is one css line to change the color



                                              .mat-focused{ color:red!important;}





                                              share|improve this answer


























                                                -1












                                                -1








                                                -1







                                                Here is one css line to change the color



                                                .mat-focused{ color:red!important;}





                                                share|improve this answer













                                                Here is one css line to change the color



                                                .mat-focused{ color:red!important;}






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Mar 7 '17 at 12:34









                                                Bhupinder kumarBhupinder kumar

                                                642317




                                                642317






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Stack Overflow!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35781631%2fmaterial-ui-changing-the-color-of-inputs-floating-label%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    MongoDB - Not Authorized To Execute Command

                                                    How to fix TextFormField cause rebuild widget in Flutter

                                                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith