I am using simple form-field input
component as in below code
<mat-form-field class="example-form-field" >
<input matInput type="search" placeholder="Search" >
</mat-form-field>
On entering the input fieled by default the placeholder will go above.
How can i hide the placeholder on entering to the input field?
You can try:
DEMO ----> Solution
In TS:
This is a only-CSS solution that worked for me.
The first CSS directive is for when the input is focused.
The second is for when the input has a valid value and is not focused.
I came into this question when looking for a way of hiding the placeholder when the input field is not empty, the solution I found is a modification of Krishna's, replacing the
mat-form-field
floatLabel
argument fromalways
tonever
:you can try this solution.
use
[floatLabel]="'always'"
I have create a demo on Stackblitz