【发布时间】:2020-04-03 16:19:20
【问题描述】:
我正在开发一个项目并利用 React Material UI,并且需要在焦点状态下覆盖 Select 组件的边框底部颜色。这是我现在正在使用的
import { Select as MuiSelect, withStyles } from '@material-ui/core';
import { BRAND_COLORS } from '../../constants/colors';
const FONT_SIZE = 20;
const Select = withStyles({
root: {
fontSize: FONT_SIZE,
'&:focus': {
backgroundColor: 'transparent',
},
'& .MuiInput-underline:after': {
borderBottomColor: BRAND_COLORS.blue,
},
},
})(MuiSelect);
export default Select;
<Select
native
startAdornment={<InputAdornment position="start"><FilterListIcon /></InputAdornment>}
value={service.regionalFocus}
onChange={(event) => this.props.changeSelectedRegionalFocus({
providerId, serviceId: service.service_id, regionalFocus:
event.target.value})
}
>
{regionalFocus.map((region, index) => service.service_regions[region.value].length ? (
<option key={index} value={region.value}>
{region.label}
</option>
) : null)}
</Select>
我可以覆盖字体大小,但是,borderBottomColor 没有注册。有什么想法吗?
【问题讨论】:
-
选择组件在其中安装一个输入。您能否提供实际呈现选择的方式?
-
我只是查看了正在安装的内容,但没有输入。这只是呈现一个包含选项的选择。
-
实际上是一个 mui 输入。请提供您如何使用选择
-
下面是我如何实现 Select
标签: reactjs material-ui react-with-styles