I am struggling to change the background of a custom component using mat-checkbox. I have tried various CSS solutions but none seem to work.
Here is my template code:
<form novalidate [formGroup]="form">
<mat-form-field>
<mat-label>{{labelText}}</mat-label>
<mat-select class="select" #select [multiple]="multiselect" [formControl]="selectField" >
<div class="select-all">
<mat-checkbox *ngIf="multiselect" [(ngModel)]="allSelected"
class="mat-check-all"
[ngModelOptions]="{standalone: true}"
[indeterminate]="isIndeterminate()"
[checked]="isChecked()"
(click)="$event.stopPropagation()"
(change)="toggleAllSelection($event)">{{text}}</mat-checkbox>
</div>
<mat-option *ngFor="let item of data" [value]="item[idField]">
{{item[fieldName]}}
</mat-option>
</mat-select>
</mat-form-field>
</form>
I have attempted the following CSS styles without success:
.mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
.mat-check-all .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
.select-all .mat-check-all .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
.select .select-all .mat-check-all .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
::ng-deep .select .select-all .mat-check-all .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
None of the above CSS changes had any effect on the checkbox. When I used:
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: rgb(49, 201, 11);
}
it affected all checkboxes in the form, not just the one in my component. How can I target only the checkbox within my custom component?