简体   繁体   中英

ANGULAR: How to change the * required in material?

I want the "*" that is required in input to be color red. I imported and use reactive forms and angular materials for this. No CSS yet for this because I dont know how to edit it with the required element in input.

Click to see Image

<form (ngSubmit)="changePassword()">
          <mat-form-field floatLabel="always">
            <input required type="password"  matInput placeholder="Old password">
          </mat-form-field>

The CSS selector is

.mat-placeholder-required.mat-form-field-required-marker {
  color: red;
}

See it in action

Be sure to either make a deep styling if you style it in your components, or to put in a global styling file, such as style.css (like I did)

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