简体   繁体   中英

How to remove the focus from today's date in Angular Material Datepicker?

Is it possible to remove the focus on today's date when using Angular Material datepicker? I have tried adding the following properties to mat-datepicker but nothing seems to work and I can't find a way to do this:

  • restoreFocus="false"
  • [startAt]="null"
    <mat-form-field appearance="fill">
       <mat-label>Choose a date</mat-label>
       <input matInput [matDatepicker]="picker">
       <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
       <mat-datepicker #picker></mat-datepicker>
    </mat-form-field>

For example, I don't want the focus/background on 16 in the image below.

角材料日期选择器

I need to do this because I am trying to use Angular Material datepicker for the users to enter their date of birth and the focus on today's date is irrelevant in this case.

apply This class inside style.css file of your project and re run project again.. Basically you need to change default css class implementation.

.mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical) {
  background-color: rgb(255 255 255) !important;
  border: none !important;
 }

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