Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material 10 date-picker (mat-datepicker) does not align with others input fields

Using Angular 10 and Angular material 10, using a datepicker in a form doesn't align with other input form field, as in this figure: fields not aligned

Example code in ~component.html:

<mat-form-field color="primary" appearance="fill">
    <mat-label>Data Da</mat-label>
    <input matInput [matDatepicker]="picker1" [(ngModel)]="dataDa">
    <mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
    <mat-datepicker #picker1 color="primary"></mat-datepicker>
</mat-form-field>

<mat-form-field class="example-form-field" appearance="fill">
    <mat-label>Ora Da</mat-label>
    <input matInput type="text" [(ngModel)]="oraDa">
</mat-form-field>

Do you have same issue if you try it?

like image 867
Daniele Privitera Avatar asked Mar 11 '26 08:03

Daniele Privitera


1 Answers

It seems to be a bug. I found this solution: in the ~component.scss file I've put this css rule:

::ng-deep mat-datepicker-toggle.mat-datepicker-toggle button.mat-focus-indicator.mat-icon-button.mat-button-base {
  display: inherit;
}
like image 118
Daniele Privitera Avatar answered Mar 13 '26 03:03

Daniele Privitera



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!