admin管理员组文章数量:1310193
Here is my current set up for a TextField ponent:
const styles = {
resize: {
fontSize: '50px',
}
}
const textField = (props) => {
const { classes } = props;
return (
<TextField
value={props.value}
placeholder={'$'}
variant={'outlined'}
onChange={props.onChange}
autoFocus
InputProps={{
classes: {
input: classes.resize
}
}}
/>
);
};
export default withStyles(styles)(textField);
When clicking in the text field the border fades away (to a white color). I want the border to stay no matter what and not fade. I tried looking through the material-ui examples for an outlined textfield and came across the "Bare" one which had a fixed border but cannot get it to work in my case. I think I have to dig down through the wrapper ponents and set the style for the border somewhere? Im not sure.
Here is my current set up for a TextField ponent:
const styles = {
resize: {
fontSize: '50px',
}
}
const textField = (props) => {
const { classes } = props;
return (
<TextField
value={props.value}
placeholder={'$'}
variant={'outlined'}
onChange={props.onChange}
autoFocus
InputProps={{
classes: {
input: classes.resize
}
}}
/>
);
};
export default withStyles(styles)(textField);
When clicking in the text field the border fades away (to a white color). I want the border to stay no matter what and not fade. I tried looking through the material-ui examples for an outlined textfield and came across the "Bare" one which had a fixed border but cannot get it to work in my case. I think I have to dig down through the wrapper ponents and set the style for the border somewhere? Im not sure.
Share Improve this question asked Oct 15, 2018 at 23:42 NumnumberryNumnumberry 3951 gold badge4 silver badges17 bronze badges2 Answers
Reset to default 4Taking from my indepth answer https://github./mui-org/material-ui/pull/13105#issuement-427459843 you could add styles to the notchedOutline
class.
<TextField classes={{ notchedOutline: myClassnameWithCustomStyles }} />
Demo: https://codesandbox.io/s/ppmxn3rp9x
This currently has some limitation which I laid out in the linked ment.
This is what worked for me.
In your style file have this
underline: {
"&:after": {
borderBottomColor: "rgb(70, 197, 29)",
borderWidth: "1px"
}
}
And then in my TextField I will implement the abobe within the InputProp
property
<TextField
id="standard-number"
label="Number"
required
autoFocus
classes={{
root: classes.space,
}}
value={some_value}
onChange={e =>
this.setState({
some_value: e.target.value
})
}
error={some_value === "" || some_value < 0}
helperText={
qty_in_mts === ""
? "Please enter Quantity (in M. Tons)"
: " "
}
label="Quantity (M. Tons)"
type="number"
fullWidth
InputProps={{
classes: {
underline: classes.underline
}
}}
/>
本文标签: javascriptHow to style the border of a MUI outlined TextFieldStack Overflow
版权声明:本文标题:javascript - How to style the border of a MUI outlined TextField? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741846868a2400830.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论