First 10% one background color ,another 90% another background color.
<TextField
className={classes.root}
type="text"
placeholder="username"
variant="outlined"
style={{borderRadius:'50',
backgroundColor: "white"
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<PersonIcon />
</InputAdornment>
)
}}
/>
I attach demo textfield in below
This is how you override the InputAdornment
to achieve the same effect in your screenshot. Note that the input
next to the InputAdornment
has its box-sizing
set to content-box
, so it's not as simple as setting the height
to 100%
in the adornment. I had to copy the padding code here to make sure the height of the adornment is the same as the height of the OutlinedInput
:
<TextField
placeholder="With normal TextField"
sx={{
"& .MuiOutlinedInput-root": {
paddingLeft: 0
}
}}
InputProps={{
startAdornment: (
<InputAdornment
sx={{
padding: "27.5px 14px",
backgroundColor: (theme) => theme.palette.divider,
borderTopLeftRadius: (theme) =>
theme.shape.borderRadius + "px",
borderBottomLeftRadius: (theme) =>
theme.shape.borderRadius + "px"
}}
position="start"
>
kg
</InputAdornment>
)
}}
V5
V4
You can do this in simple way .Try this one
InputProps={{
startAdornment: (
<div style={{display:'flex',flexDirection:'column',justifyContent:'center',alignContent:'center', backgroundColor:'#E1E8EB',height:55,width:50,marginLeft:-13,border:'0px solid green',marginRight:5}}>
<InputAdornment position="start">
<VpnKeyIcon style={{marginLeft:10}} />
</InputAdornment>
</div>
)
}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.