Search code examples
angular-material

Angular Material: mat-checkbox vertical alignment of checkbox


I can't seem to override the defaults to vertically align the checkbox relative to the checkbox label. Searched for a while but nothing has worked. See example image:

enter image description here

Should be like:

enter image description here

Have tried the following:

.mat-checkbox-inner-container {
    margin: none;
}

HTML:

<label><b>Home Type</b></label>
    <mat-checkbox>Entire place<br><small class="text-muted">Have a place to yourself</small></mat-checkbox>
    <mat-checkbox>Private room<br><small class="text-muted">Have your own room and share some common spaces</small></mat-checkbox>
    <mat-checkbox>Shared room<br><small class="text-muted">Stay in a shared space, like a common room</small></mat-checkbox>

Solution

  • Similar to Craig's answer but as a descendant of .mat-checkbox.mat-accent to spare the need of using "!important"

    .mat-checkbox.mat-accent .mat-checkbox-inner-container {
        margin: 2px 8px auto 0;
    }
    

    or using sass/less

    .mat-checkbox.mat-accent {
       .mat-checkbox-inner-container {
          margin: 2px 8px auto 0;
       }
    }