I'm using checkbox of angular-material2. Currently the default color of checkbox is coming as purple color.
Looks like they have changed default color of checkbox from "primary" to accent.
Is there a way to get "primary"(green) color instead of purple without overriding css.
I tried giving color="primary" to but that didn't worked.
Code : <md-checkbox></md-checkbox>
Import statement:
import {MdCheckbox} from '@angular2-material/checkbox';
Plunker http://plnkr.co/edit/sFC0kfdzj7fxtUC3GXdr?p=preview
Explanation: The checked background color is changed to mat-checkbox-background within mat-checkbox-checked. IF you want to modify the background color when it is not checked just copy that part and copy it outside of mat-checkbox-checked.
“:hover” is used to style the checkbox when user hovers over it. Notice that when the mouse pointer move over the checkbox the color of it changes to yellow. “:active” is used to style the checkbox when it is active. Notice that when click the checkbox it will first notice a red color and then the green color.
First mistake you made is you are adding (change) event on button click. Replace it with (click) as change event if for input type properties and you can only use it with ngModel. You should add isChecked property inside appUserRoleList list, which will help you to check/uncheck checkbox.
You don't have to add css if you'r using theme, just add attribute color to <mat-checkbox>
<mat-checkbox color="primary">Primary</mat-checkbox>
The color of a
<mat-checkbox>
can be changed by using the color property. By default, checkboxes use the theme's accent color. This can be changed to 'primary' or 'warn' Checkbox | Angular Material
For Angular Material 7, works for outline color and inside filled in color
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-ripple .mat-ripple-element { opacity: 0.03 !important; background-color: #005691!important; } ::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background,.mat-checkbox-indeterminate.mat-accent .mat-checkbox-background { background-color: #005691; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With