简体   繁体   English

居中默认 TextField 提示 - MaterialUI

[英]centering the default TextField hint - MaterialUI

I was getting started with material UI and was trying to get the TextField component to behave the way I wanted.我开始使用Material UI ,并试图让TextField组件按照我想要的方式运行。 The animation that it gives by default is cool, yet, I wanted it to align it to the center, yet it sticks to the top left:它默认提供的 animation 很酷,但是,我希望它与中心对齐,但它却粘在左上角:

在此处输入图像描述

I want the Email Address hint that is in the TextField outline to be positioned like that in the center of the top outline.我希望将TextField轮廓中的Email Address提示定位在顶部轮廓的中心。 How do I do that?我怎么做?

you can pass a style Object in the inputProps like this:您可以像这样在inputProps中传递样式 Object :
<TextField inputProps={{style:{textAlign:"center"}}} id="outlined-basic" label="Outlined" variant="outlined" />
here sandBox example这里是沙盒示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM