![](/img/trans.png)
[英]Angular Material form-field outline input color change when the form-field is active
[英]Angular material form field input - green border when input is valid
我认为如果你使用材质主题,你可以在 mat-form-field 元素中使用颜色属性
到目前为止,我找到了适合我的解决方案。 我不是 css 专业人士,所以如果这有任何副作用,我很乐意了解它。
编辑:我读了你说没有 CSS 覆盖的部分,这里是一个线程,有不同的方法来改变边框颜色,也许有一些你可以接受的答案。
样式.css:
mat-form-field {
// &.ng-valid {
&.mat-form-field-valid { <- I have custom async validators which execute on submit so I just add a custom class when the form is valid
.mat-form-field-outline {
color: green !important;
border-width: 2px;
}
.mat-form-field-label {
color: green;
}
.mat-form-field-outline-start {
border-width: 2px;
}
.mat-form-field-outline-gap {
border-width: 2px;
}
.mat-form-field-outline-end {
border-width: 2px;
}
}
}
html:
<mat-form-field appearance="outline" [ngClass]="{'mat-form-field-valid': form?.valid }">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.