angularcheckboxangular-materialcss-transforms

Change the size of angular material checkbox (mat-checkbox)


I'm trying to increase the size of the material checkbox.

transform seems to increase the size of the material checkbox. However, I'm not sure if this is a correct way to achieve that?

CSS

 ::ng-deep .mat-checkbox .mat-checkbox-frame {
     transform: scale(2);
 }

 ::ng-deep .mat-checkbox-checked .mat-checkbox-background {
     transform: scale(2);
 }

Solution

  • As ::ng-deep is deprecated, you can:

    Add encapsulation: ViewEncapsulation.None in your @Component like:

    @Component({
      selector: 'app-component',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss'],
      encapsulation: ViewEncapsulation.None
    })
    

    And in your CSS simply use this:

    .mat-checkbox .mat-checkbox-frame {
         transform: scale(2);
    }
    
    .mat-checkbox-checked .mat-checkbox-background {
         transform: scale(2);
    }