Reputation: 542
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
Upvotes: 7
Views: 12782
Reputation: 187
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>
)
}}
Upvotes: 2
Reputation: 81270
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
Upvotes: 5