Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify angular-material2 mat-checkbox left icon size and color?

angular material2 mat-checkbox

How do I modify the left icon size, and the left icon state color?

<mat-checkbox>Like Me.</mat-checkbox>
like image 718
langwan Avatar asked Feb 02 '18 08:02

langwan


People also ask

How to change mat checkbox checked color?

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.

What is Mat checkbox?

<mat-checkbox> supports an indeterminate state, similar to the native <input type="checkbox"> . While the indeterminate property of the checkbox is true, it will render as indeterminate regardless of the checked value. Any interaction with the checkbox by a user (i.e., clicking) will remove the indeterminate state.


1 Answers

You can use this ( .mat-checkbox-inner-container ) CSS class to modify the mat-checkbox

.mat-checkbox-inner-container {
  height: 50px!important;
  width: 50px!important;
}

Note that you need to put the style modification in styles.css root folder ( /src/styles.css ) and not in the components css.

Also put !important ( width: 50px!important; ) to override the default style.

Below is the default style for the mat-checkbox

.mat-checkbox-inner-container {
    display: inline-block;
    height: 20px;
    line-height: 0;
    margin: auto;
    margin-right: 8px;
    order: 0;
    position: relative;
    vertical-align: middle;
    white-space: nowrap;
    width: 20px;
    flex-shrink: 0;
}

Hope this helps.

like image 76
davecar21 Avatar answered Sep 28 '22 03:09

davecar21