Material UI changing the color of inputs floating label
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
add a comment |
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
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
add a comment |
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
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
javascript css reactjs material-ui
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
add a comment |
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
add a comment |
5 Answers
5
active
oldest
votes
You should use floatingLabelFocusStyle:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />
add a comment |
You should set style of InputLabel:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField
label="Test"
id="test"
InputLabelProps={{
className: classes.floatingLabelFocusStyle,
}}
/>
add a comment |
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.
add a comment |
This does the tick
InputLabelProps={{
style: { color: '#fff' },
}}
add a comment |
Here is one css line to change the color
.mat-focused{ color:red!important;}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You should use floatingLabelFocusStyle:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />
add a comment |
You should use floatingLabelFocusStyle:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />
add a comment |
You should use floatingLabelFocusStyle:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />
You should use floatingLabelFocusStyle:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField floatingLabelFocusStyle={styles.floatingLabelFocusStyle} />
answered Aug 18 '16 at 23:06
Jan Franz PalngipangJan Franz Palngipang
2,4211622
2,4211622
add a comment |
add a comment |
You should set style of InputLabel:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField
label="Test"
id="test"
InputLabelProps={{
className: classes.floatingLabelFocusStyle,
}}
/>
add a comment |
You should set style of InputLabel:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField
label="Test"
id="test"
InputLabelProps={{
className: classes.floatingLabelFocusStyle,
}}
/>
add a comment |
You should set style of InputLabel:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField
label="Test"
id="test"
InputLabelProps={{
className: classes.floatingLabelFocusStyle,
}}
/>
You should set style of InputLabel:
const styles = {
floatingLabelFocusStyle: {
color: "somecolor"
}
}
<TextField
label="Test"
id="test"
InputLabelProps={{
className: classes.floatingLabelFocusStyle,
}}
/>
answered Sep 17 '18 at 15:10
BorzhBorzh
3,12813047
3,12813047
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 3 '16 at 20:55
Bharath RajaBharath Raja
18911
18911
add a comment |
add a comment |
This does the tick
InputLabelProps={{
style: { color: '#fff' },
}}
add a comment |
This does the tick
InputLabelProps={{
style: { color: '#fff' },
}}
add a comment |
This does the tick
InputLabelProps={{
style: { color: '#fff' },
}}
This does the tick
InputLabelProps={{
style: { color: '#fff' },
}}
answered Jan 1 at 19:59
Malte Schulze-BoeingMalte Schulze-Boeing
38529
38529
add a comment |
add a comment |
Here is one css line to change the color
.mat-focused{ color:red!important;}
add a comment |
Here is one css line to change the color
.mat-focused{ color:red!important;}
add a comment |
Here is one css line to change the color
.mat-focused{ color:red!important;}
Here is one css line to change the color
.mat-focused{ color:red!important;}
answered Mar 7 '17 at 12:34


Bhupinder kumarBhupinder kumar
642317
642317
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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