My goal is to display text Fields and checkboxes side by side, similar to the layout shown in this image: https://i.sstatic.net/7QyLy.png
However, I am facing an issue with aligning <mat-form-field>
and <mat-checkbox>
vertically.
How can I resolve this alignment problem?
Below is the code snippet:
<mat-card>
<mat-card-title>
Family Information
</mat-card-title>
<form [formGroup]="familyInfo">
<div fxLayout="row" fxLayoutAlign="flex-start" fxLayoutGap="40px">
<mat-form-field fxFlex="10%">
<mat-label>Contact Name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field fxFlex="10%">
<mat-label>Relation Type </mat-label>
<mat-select>
<mat-option *ngFor="let relationType of relationTypes" [value]="relationType" color="accent">
{{relationType}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="10%">
<mat-label>Gender </mat-label>
<mat-select>
<mat-option *ngFor="let gender of genders" [value]="gender" color="accent">
{{gender}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="10%">
<mat-label>Date Of Birth</mat-label>
<input matInput [matDatepicker]="dateOfBirth" formControlName="dateOfBirth">
<mat-datepicker-toggle matSuffix [for]="dateOfBirth"></mat-datepicker-toggle>
<mat-datepicker #dateOfBirth></mat-datepicker>
</mat-form-field>
<mat-checkbox formControlName="isDependent">Is Dependent</mat-checkbox>
<div fxFlex="100%"></div>
<mat-card-actions>
<button mat-raised-button color="primary" type="submit" class="align-right-button">
Save
</button>
</mat-card-actions>
</div>
I attempted using <mat-form-field>
, but according to Angular Material documentation, <mat-checkbox>
cannot be nested within <mat-form-field>
.