【发布时间】:2021-05-17 11:46:19
【问题描述】:
我有TextField。因为 Material UI 有 Alarm Clock 图标。
材料 UI 文档是这样的:
<form className={classes.container} noValidate>
<TextField
id="time"
label="Alarm clock"
type="time"
defaultValue="07:30"
className={classes.textField}
InputLabelProps={{
shrink: true,
}}
inputProps={{
step: 300, // 5 min
}}
/>
</form>
我的设计是这样的:
<TextField
id="time"
type="time"
style={{
width: "148px",
marginLeft: 4,
marginRight: 6,
padding: "2px 0px 3px 6px",
}}
defaultValue="03:30"
value={timeChange}
onChange={handleTimeChange}
className={classes.textField}
color="secondary"
InputProps={{
disableUnderline: true,
endAdornment: <ExpandMoreIcon style={{ color: "gray" }} />,
classes: {
input: classes.floatingLabelFocusStyle,
},
// className: classes.input,
}}
/>;
并添加了一些 CSS:
input[type="time"]::-webkit-calendar-picker-indicator {
background: none;
}
我得到了什么:
有没有办法让ExpandMoreIcon 在点击时表现得像闹钟一样并打开弹出窗口以显示时间选择器?
我不想显示闹钟图标。我只想要ExpandMoreIcon图标中的闹钟功能?
有什么解决办法吗?
谢谢。
【问题讨论】:
标签: javascript html css reactjs