![](/img/trans.png)
[英]Trying to change active tab color, don't know what I am doing wrong in my code
[英]I am trying to add the Material-UI InfoIcon into my code. But I don't know how to implement it in TextField
我正在嘗試將Material-UI InfoIcon - >添加到我的代碼中。 但我不知道如何在TextField中實現它。
這是材料-UI代碼:
<InfoIcon fontSize="small" />
這是我想要的地方:
<Grid item xs={5}>
<TextField
id="createdate"
label="Create Date"
value={dateCheck(workOrderDetail.reported_date, 'll') }
variant="filled"
disabled
fullWidth
inputProps={{ style: style.textFieldInput }}
/>
</Grid>
您應該將您的圖標與InputAdornment
組件放在一起。 我為您創建了一個快速演示:
import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField';
import Grid from '@material-ui/core/Grid';
import InfoIcon from '@material-ui/icons/InfoIcon';
<TextField
id="createdate"
label="Create Date"
value={dateCheck(workOrderDetail.reported_date, 'll') }
variant="filled"
disabled
fullWidth
InputProps={{
style: style.textFieldInput,
startAdornment: (
<InputAdornment position="start">
<AccountCircle />
</InputAdornment>
),
}}
/>
所以我這樣做是為了使造型正確。 我做了一個功能:
const label = () => {
return (
<React.Fragment>
Create Date <InfoIcon fontSize='small'></InfoIcon>
</React.Fragment>
)
}
<Grid item xs={5}>
<TextField
id="createdate"
label={label()}
value={dateCheck(workOrderDetail.reported_date, 'll') }
inputProps={{ style: style.textFieldInput }}
variant="filled"
disabled
fullWidth
/>
</Grid>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.