[英]How do you create a InputAdornment IconButton that's flush with an OutlinedInput in Material-UI?
I'm trying to reproduce a text input from a mockup and am having trouble making it match.我正在尝试从模型复制文本输入,但无法使其匹配。 The project I'm working on uses Material-UI, so it needs to be made up of components from that library.
我正在处理的项目使用 Material-UI,因此它需要由该库中的组件组成。 Initially I tried rendering a button next to the input, but that didn't look good at all and would be unacceptable.
最初我尝试在输入旁边渲染一个按钮,但这看起来一点也不好看,而且是不可接受的。 When I moved onto trying InputAdornments, I am getting closer but can't seem to be able to get the button flush with the input, like in the mockup.
当我开始尝试 InputAdornments 时,我越来越近了,但似乎无法让按钮与输入齐平,就像在模型中一样。
Below is the code that I have so far.下面是我到目前为止的代码。 If anyone has any ideas I'd be very grateful!
如果有人有任何想法,我将不胜感激!
<OutlinedInput
id="outlined-add-region"
type="text"
value="Ajouter une région"
onChange={handleChange("password")}
endAdornment={
<InputAdornment position="end">
<button
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
edge="end"
>
<Add />
</button>
</InputAdornment>
}
/>
I played around with it a bit on code sandbox and got it close to your mockup.我在代码沙箱上玩了一下,让它接近你的模型。
Perhaps this will get you started:也许这会让你开始:
<OutlinedInput
style={{height: "40px", width: "250px"}}
id="outlined-add-region"
type="text"
value="Ajouter une région"
onChange={() => {}}
endAdornment={
<Button
style={{
position: "absolute",
right: 0,
height: "100%",
backgroundColor: "#f0f8ff",
color: "#5072a7",
}}
>
<Add style={{fontSize: "25px"}} />
</Button>
}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.