简体   繁体   中英

How to disable the angular material placeholder flying above the input

I've an Angular Material input. In most forms, when I click on it, I like the behavior(having the placeholder going above the input). But in some cases I need this place holder to just disappear.

Also, I need the control to not use some white space "above" the input.

1) Is it possible? How?

2) If not, what would you do to still use the style of the theme(text color, no border, size, ...) of the angular material theme ?

Not sure it helps, but here is an example where I don't want it(the search text): https://stackblitz.com/edit/angular-scgar8

The material field has a floatLabel property.

You can set this to never to get your desired result.

<mat-form-field floatLabel="never">
  <input matInput placeholder="search">
</mat-form-field>

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.

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