reactjs - 在 MUI 中更改 TextField 字体颜色?
问题描述
我目前正在使用MUI。
而且我在尝试更改 multiline 的字体颜色时遇到问题TextField
。
<TextField className = "textfield"
fullWidth
multiline
label = "Debugger"
rows = "10"
margin = "normal"/>
和CSS:
.textfield {
background-color: #000;
color: green;
}
但是,不知何故,我只得到黑色背景,字体仍然是黑色的。有谁知道如何正确更改TextField
使用 MUI 的字体颜色?
解决方案
我提到了这个页面TextField API
我使用类覆盖 TextField
const styles = theme => ({
multilineColor:{
color:'red'
}
});
使用 InputProps 将类应用到 TextField。
<TextField
className = "textfield"
fullWidth
multiline
InputProps={{
className: classes.multilineColor
}}
label = "Debugger"
rows = "10"
margin = "normal" />
编辑在旧版本中,您必须指定密钥input
<TextField
className = "textfield"
fullWidth
multiline
InputProps={{
classes: {
input: classes.multilineColor
}
}}
label = "Debugger"
rows = "10"
margin = "normal"
/>
希望这会奏效。
推荐阅读
- javascript - 在 JavaScript 中过滤数组以使其变得唯一
- javascript - Node.js + Discord.js:无法读取未定义的属性“类”
- postgresql - Kafka 消息未插入数据库
- javascript - 第一行代码之前的 Discord.js 模块错误
- r - R:因子分析分数与因子载荷计算不同(心理)
- python - Django模板“pluralize”过滤器导致原始文本输出
- flutter - 使用不包含 Scaffold 的上下文调用 Scaffold.of()。问题
- python - Selenium 安装 geckodriver
- julia - 迭代 Tuple DataType 中的类型
- javascript - 将来自 json 的传入数据转换为二维数组