Changing border color in mat-form-field

前端 未结 8 1488
猫巷女王i
猫巷女王i 2020-12-14 22:59

I am using angular material mat-form-field. I have a dark background, and therefore am trying to change the border of the form-field to white. But I am not able

8条回答
  •  臣服心动
    2020-12-14 23:44

    HTML

    
         Transaction Number
         
    
    

    SCSS

    $color-outline: red;
    
    mat-form-field {
       &.border-red {
          // to change border color
          ::ng-deep .mat-form-field-outline {
               color: $color-outline !important;
          }
          // to change label color
          ::ng-deep .mat-form-field-label {
               color: $color-outline !important;
          }
       }
    }
    

    this will work only if you give .border-red class to your mat-form-field.

    If you want to apply on all mat-form-field (remove border-red style rule)

    $color-outline: red;
    
    mat-form-field {
          // to change border color
          ::ng-deep .mat-form-field-outline {
               color: $color-outline !important;
          }
          // to change label color
          ::ng-deep .mat-form-field-label {
               color: $color-outline !important;
          }
    }
    

提交回复
热议问题