javascript - material-ui 组件样式自定义 - 将选择组件的颜色更改为白色
问题描述
我想使用 material-ui 组件的下拉菜单(请参阅https://material-ui.com/components/selects/)。因此,我从示例中复制了特定组件:
零件
return <div>
<FormControl variant="outlined" className={classes.root}>
<InputLabel ref={inputLabel} id="demo-simple-select-outlined-label">
Plan
</InputLabel>
<Select
labelId="demo-simple-select-outlined-label"
id="demo-simple-select-outlined"
value={age}
onChange={handleChange}
labelWidth={labelWidth}
>
<MenuItem value="">
<em>None</em>
</MenuItem>
<MenuItem value={10}>dsnfsdjfnsduifn</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>
</FormControl>
风格
const useStyles = makeStyles(theme => ({
root: {
margin: theme.spacing(1),
minWidth: 120,
color: 'white',
borderColor: 'white'
},}));
由于我的应用程序设计,我想将此下拉菜单的颜色更改为白色。目前该组件如下所示:
正如您在组件中看到的那样,变体被概述了。据我了解文档(https://material-ui.com/api/select/),我必须覆盖 .MuiSelect-outlined 类,但我不确定如何做到这一点。不幸的是,该手册只描述了简单按钮的样式,而不是我如何更改此类更复杂组件的样式。我希望有人能给我一个例子,我如何将轮廓、文本和箭头的颜色更改为白色。
解决方案
给你
.MuiOutlinedInput-notchedOutline {
border-color: #fff;//for border color
}
.MuiSelect-icon {
color: #fff;// for icon drop down icon color
}
.MuiInputLabel-root {
color: #fff;// for lable color
}
只需在这些上focus
添加父.Mui-focused
选择器
推荐阅读
- assembly - MIPS 程序集 (MARS) 中的 .align 指令
- reactjs - 如何在 react-data-grid 中隐藏列
- bash - 如何处理空间值 - Unix KSH 脚本
- sql - SQL - 需要像日期时间的在线离线状态
- google-bigquery - 如何为在 BigQuery 中创建的表选择分区?
- python - Pandas:要保存以包含 dtypes 的文件类型
- c# - 为什么这个布尔值不是线程安全的?
- c# - 将 A* 更新为跳转点搜索
- java - 构造函数 SomeClass() 已经在类 SomeClass 中定义
- c++ - 如何使用通过 MMDevice API 访问音频设备?