Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't bind to 'shouldLabelFloat' since it isn't a known property of 'input'

Based on the api documentation, shouldLabelFloat is a property of MatInput. But I'm still getting the error.

<mat-form-field>
  <input matInput [shouldLabelFloat]="true" placeholder="First Name">
</mat-form-field>
like image 965
Manoj Shrestha Avatar asked Dec 31 '25 09:12

Manoj Shrestha


1 Answers

After a bit of digging, it looks like the documentation site is a bit broken and shows properties that are meant to be private. There's currently a pull request that was already merged with this fix to remove private getters. Here's the code for more info.


Anyways, the correct property to use is the floatLabel input of MatFormField as follows:

<mat-form-field floatLabel="always">
  <input matInput [(ngModel)]="firstName" placeholder="First name">
</mat-form-field>

The floatLabel input accepts three properties: auto, always or never.


Here's some references:

  • Api documentation for MatFormField
  • Overview docs on placeholders
  • Stackblitz Demo
like image 192
Edric Avatar answered Jan 06 '26 06:01

Edric



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!