I'm trying to horizontally align the radio/checkboxes in different types of Angular Material form controls in a list. The list is a mix of mat-list-option, mat-checkbox and mat-radio-button. I need the labels to be left aligned while the checkbox/radio buttons to be right aligned.
I've tried using fxLayouts "row" and "space-between" without luck. I've also tried to tamper with the css but cannot seem to get it right. I've created a StackBlitz for it: https://stackblitz.com/edit/material-6-kj87kz
<mat-selection-list>
<ng-container *ngFor="let text of texts">
<mat-list-option [checkboxPosition]="'after'">
{{ text }}
</mat-list-option>
<div style="padding: 0 16px">
<mat-checkbox *ngIf="isCheckbox" fxLayout="row" fxLayoutAlign="space-between center">
{{ text }}
</mat-checkbox>
<mat-radio-group *ngIf="isRadioGroup" fxLayout="column" fxLayoutAlign="space-between center">
<mat-radio-button *ngFor="let subText of subTexts" fxLayout="row" [labelPosition]="'before'">
{{ subText }}
</mat-radio-button>
</mat-radio-group>
</div>
</ng-container>
</mat-selection-list>
Notice that I've removed bindings, conditions and actions from the code to keep it simple. This is what I currently get:
As you can see, I struggle to get the controls aligned. Do anyone know of a good approach on how to accomplish this?
StackBlitz: https://stackblitz.com/edit/material-6-kj87kz