Customizing mat-checkbox

Viewed 139

I would like to change the angular material mat-checkbox checked icon. By default, the check icon is a white tick icon shown in a colored background box. What I need is a cross instead of tick (single problem, just show cross instead of tick when it is checked). The whole day searching, could not find a proper solution for that. Would be really appreciated for any ideas with sample codes. I am using Angular 10 and scss styling.

What I want to do

1 Answers

You can replace checkbox's default svg with any svg here. Just you have to manipulate you dom.

Here is the minimal working example you can achieve link

I have used document which is not recommended to manipulate dom in Angular.

You can check other methods for eg. renderer2, hostbinding, etc.

Related